index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" @click="onShow" >{{$t(title)}}</el-button>
  4. <el-drawer
  5. :title="$t(`添加商品`)"
  6. :visible.sync="dialogFormVisible"
  7. size="90%"
  8. direction="rtl"
  9. :show-close="false"
  10. append-to-body
  11. @close="onClose">
  12. <div class="drawer__panel" style="padding-bottom: 36px;">
  13. <div class="flex-between">
  14. <uploadAllData
  15. class="inline-16"
  16. :total="total"
  17. @handlePullApi="handlePullApi"
  18. @handleUploadApi="handleUploadApi"
  19. @onSuccess="onSuccess"
  20. ></uploadAllData>
  21. <el-button :disabled="items.length === 0" :type="items.length > 0?'primary':''" size="small" class="inline-24 bottom-margin" @click="batchAdd">{{$t(`添加选中商品`)}}</el-button>
  22. <el-input style="width:200px;" :placeholder="$t(`商品名称/编码/品号`)" :suffix-icon="params.content.where.condition?params.content.where.condition.length > 0?'':'':'el-icon-search'" v-model="params.content.where.condition" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="input-with-select inline-24 layout_search__panel bottom-margin" clearable>
  23. </el-input>
  24. <el-input style="width:200px;" :placeholder="$t(`型号`)" :suffix-icon="params.content.where.model?params.content.where.model.length > 0?'':'':'el-icon-search'" v-model="params.content.where.model" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
  25. </el-input>
  26. <el-input style="width:200px;" :placeholder="$t(`规格`)" :suffix-icon="params.content.where.spec?params.content.where.spec.length > 0?'':'':'el-icon-search'" v-model="params.content.where.spec" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
  27. </el-input>
  28. <slot name="optionSystem"></slot>
  29. </div>
  30. <selectClass ref="class" @clickAreaBase="clickAreaBase" @brandChange="brandChange" @onClassChange="onClassChange" @Search="Search" @clearSearch="clearSearch" @clickField="clickField" :default="true"></selectClass>
  31. <div style="width: 100%;border-bottom: 1px solid #ebeef5;margin-bottom: 10px;"></div>
  32. <div >
  33. <tableTemp ref="tableTemp" :data="list" :layout="tablecolsAdd" :opwidth="200" :custom="true" height="calc(100vh - 370px)" @checkboxCallBack="checkboxCallBack" fixedName="operation">
  34. <template v-slot:customcol="scope">
  35. <p v-if="scope.column.columnname === 'cover'">
  36. <previewImage v-if="scope.column.data.attinfos[0]" class="image" :image="scope.column.data.attinfos[0]" :list="scope.column.data.attinfos" :deletebtn="false"></previewImage>
  37. </p>
  38. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  39. </template>
  40. <template v-slot:opreation="scope">
  41. <el-button type="text" size="mini" @click="addProduct(scope)">{{$t(`添 加`)}}</el-button>
  42. </template>
  43. </tableTemp>
  44. <div class="container normal-panel" style="text-align:right">
  45. <el-pagination
  46. background
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :current-page="params.content.pageNumber"
  50. :page-sizes="[20, 50, 100, 200]"
  51. :page-size="100"
  52. layout="total,sizes, prev, pager, next, jumper"
  53. :total="total">
  54. </el-pagination>
  55. </div>
  56. </div>
  57. </div>
  58. </el-drawer>
  59. </div>
  60. </template>
  61. <script>
  62. import tableTemp from './table'
  63. import uploadAllData from '@/components/uploadAllData/index'
  64. import previewImage from '@/components/previewImage/index'
  65. import selectClass from '@/SDrpManagement/ProductGroup/modules/Select2.vue'
  66. export default {
  67. name: "index",
  68. props:["data","tradefield","discountrate","params","title","tablecolsAdd","sa_projectid","querySa_brandid","typeName"],
  69. components:{tableTemp,uploadAllData,previewImage,selectClass},
  70. provide () {
  71. return {
  72. sys_enterpriseid:() => ''
  73. }
  74. },
  75. data(){
  76. return {
  77. dialogFormVisible:false,
  78. sa_brandid:'',
  79. itemclassid:'',
  80. itemstandard:'',
  81. itemmaterial:'',
  82. list:[],
  83. total:0,
  84. options:{
  85. brands:[],
  86. itemclass:[],
  87. itemstandards:[],
  88. itemmaterials:[]
  89. },
  90. items:[]
  91. }
  92. },
  93. methods:{
  94. onShow(){
  95. this.dialogFormVisible = true
  96. // this.params = {
  97. // "id": 20221124093602,
  98. // "content": {
  99. // "sa_contractid": this.$route.query.id,
  100. // "pageNumber": 1,
  101. // "pageSize": 100,
  102. // "where": {
  103. // "condition": "",
  104. // "istool": 0
  105. // }
  106. // },
  107. // }
  108. this.listData(this.params.content.pageNumber = 1)
  109. },
  110. /*可添加商品*/
  111. async listData(){
  112. if (this.data){
  113. switch (this.data.type) {
  114. case '标准订单':
  115. this.params.id = 20221109153502
  116. break;
  117. case '项目订单':
  118. this.params.id = 20230103155002
  119. break;
  120. case '促销订单':
  121. this.params.id = 20230107182302
  122. break;
  123. case '工具订单':
  124. this.params.id = 20221109153502
  125. break;
  126. default:
  127. this.params.id = 20221109153502
  128. break;
  129. }
  130. }
  131. if (this.typeName === '居间'){
  132. this.params.id = 20221124093602
  133. }
  134. console.log(this.params.id);
  135. this.params.content.where.tradefield = this.tradefield
  136. const res = await this.$api.requested(this.params)
  137. this.list = res.data
  138. this.total = res.total
  139. this.$refs.tableTemp.$refs.table.doLayout()
  140. },
  141. /*获取品牌*/
  142. async queryBrands () {
  143. const res = await this.$api.requested({
  144. "id": "20220924163702",
  145. "content": {
  146. "pageSize":1000,
  147. "where":{
  148. "condition":""
  149. }
  150. }
  151. })
  152. this.options.brands = res.data
  153. console.log("获取品牌",res.data)
  154. this.sa_brandid = res.data[0].sa_brandid
  155. this.queryClass()
  156. },
  157. /*获取分类*/
  158. async queryClass () {
  159. const res = await this.$api.requested({
  160. "id":"20220922110403",
  161. "content":{
  162. "sa_brandid":this.sa_brandid !== '' ? this.sa_brandid : 0
  163. }
  164. })
  165. let arr = []
  166. function converTree(node) {
  167. var elNode = {
  168. isdeep:node["isdeep"],
  169. ishide:node["ishide"],
  170. istool:node["istool"],
  171. itemclassfullname:node["itemclassfullname"],
  172. itemclassfullnum:node["itemclassfullnum"],
  173. itemclassid:node["itemclassid"],
  174. itemclassname:node["itemclassname"],
  175. itemclassnum:node["itemclassnum"],
  176. num:node["num"],
  177. parentid:node["parentid"],
  178. rowindex:node["rowindex"],
  179. subdep:[]
  180. }
  181. if (node.subdep.length > 0) {
  182. // 如果存在子节点
  183. for (var index = 0; index < node.subdep.length; index++) {
  184. // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
  185. elNode.subdep.push(converTree(node.subdep[index]));
  186. }
  187. }else {
  188. elNode = {
  189. isdeep:node["isdeep"],
  190. ishide:node["ishide"],
  191. istool:node["istool"],
  192. itemclassfullname:node["itemclassfullname"],
  193. itemclassfullnum:node["itemclassfullnum"],
  194. itemclassid:node["itemclassid"],
  195. itemclassname:node["itemclassname"],
  196. itemclassnum:node["itemclassnum"],
  197. num:node["num"],
  198. parentid:node["parentid"],
  199. rowindex:node["rowindex"],
  200. }
  201. }
  202. return elNode;
  203. }
  204. // this.options.itemclass = arr
  205. res.data[0].ttemclass.forEach(e=>{
  206. arr.push(converTree(e))
  207. });
  208. this.options.itemclass = arr
  209. return arr
  210. },
  211. brandChange(id){
  212. this.params.content.where.sa_brandid = this.params.id == 20221021171802 || this.params.id == 20221020164903 || this.params.id == 20221124093602 || this.params.id == 20220923112503 ? id[0] : id
  213. this.$refs.class.clickClass(false)
  214. // this.listData(this.params.content.pageNumber = 1)
  215. },
  216. onClassChange (n) {
  217. this.params.content.where.itemclassid = n.itemclassid
  218. this.listData(this.params.content.pageNumber = 1)
  219. },
  220. clickField (item) {
  221. this.params.content.where.tradefield = item.tradefield
  222. this.listData(this.params.content.pageNumber = 1)
  223. },
  224. clickAreaBase (item) {
  225. this.params.content.where.standards = item
  226. this.listData(this.params.content.pageNumber = 1)
  227. },
  228. Search(data) {
  229. this.params.content.where.condition = data
  230. this.params.content.pageNumber = 1
  231. this.listData(this.params.content.pageNumber = 1)
  232. },
  233. clearSearch() {
  234. this.params.content.where.condition = ''
  235. this.params.content.pageNumber = 1
  236. this.listData(this.params.content.pageNumber = 1)
  237. },
  238. classChange(){
  239. this.params.content.where.itemclassid = this.itemclassid[this.itemclassid.length -1]
  240. this.listData(this.params.content.pageNumber = 1)
  241. },
  242. queryChange(){
  243. this.params.content.where.standards = this.itemstandard
  244. this.params.content.where.material = this.itemmaterial
  245. this.listData(this.params.content.pageNumber = 1)
  246. },
  247. /*拉取数据*/
  248. handlePullApi (pullApi) {
  249. pullApi.content = JSON.parse(JSON.stringify(this.params.content))
  250. pullApi.id = this.params.id
  251. /*pullApi.content.sa_projectid = this.$route.query.id*/
  252. },
  253. /*上传数据*/
  254. handleUploadApi (uploadApi,data) {
  255. this.$emit('uploadData',uploadApi,data)
  256. },
  257. /*勾选*/
  258. checkboxCallBack(val){
  259. this.items = val
  260. },
  261. /*批量添加*/
  262. batchAdd(){
  263. console.log(this.items,'item')
  264. this.$emit('addSuccess',this.items)
  265. },
  266. /*添加商品*/
  267. addProduct(val){
  268. console.log(val,'添加商品')
  269. this.items = val
  270. this.$emit('addProduct',this.items.data)
  271. },
  272. onSuccess () {
  273. console.log('成功')
  274. this.listData(this.params.content.pageNumber = 1)
  275. },
  276. onClose(){
  277. this.dialogFormVisible = false
  278. this.$refs.class.value= "",
  279. this.$refs.class.brands= []
  280. this.$refs.class.ields= []
  281. this.$refs.class.itemclass= []
  282. this.$refs.class.activeClass= {}
  283. this.$refs.class.field_act= ""
  284. this.$refs.class.tradefield= ""
  285. this.$refs.class.brand_act= 0
  286. this.$refs.class.class_act= ""
  287. this.$refs.class.areaBases= []
  288. this.$refs.class.areaBase= ""
  289. this.$refs.class.queryClass();
  290. this.$refs.class.queryAgentiInfo();
  291. this.$refs.class.queryBrands();
  292. this.$refs.class.queryAreaBase();
  293. this.$emit("closeDrawer")
  294. },
  295. handleSizeChange(val) {
  296. // console.log(`每页 ${val} 条`);
  297. this.params.content.pageSize = val
  298. this.listData()
  299. },
  300. handleCurrentChange(val) {
  301. // console.log(`当前页: ${val}`);
  302. this.params.content.pageNumber = val
  303. this.listData()
  304. },
  305. },
  306. mounted() {
  307. },
  308. created() {
  309. }
  310. }
  311. </script>
  312. <style scoped>
  313. .image{
  314. height: 38px;
  315. width: 38px;
  316. margin-top:0;
  317. }
  318. .top-margin{
  319. margin-top: 20px;
  320. }
  321. .bottom-margin{
  322. margin-bottom: 10px;
  323. }
  324. /deep/ input::-webkit-input-placeholder {
  325. color: #58585d;
  326. }
  327. /deep/ input::-moz-input-placeholder {
  328. color: #58585d;
  329. }
  330. /deep/ input::-ms-input-placeholder {
  331. color: #58585d;
  332. }
  333. </style>