relation_list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :operation="operation()"
  7. :tableAttributes="tableAttributes"
  8. :tableEvents="tableEvents"
  9. :optionsEvensGroup="optionsEvensGroup"
  10. :columnParsing="columnParsing"
  11. >
  12. <!-- 弹窗 -->
  13. <el-dialog
  14. title="产品信息"
  15. :visible.sync="showDialogForm"
  16. width="70%"
  17. :show-close="false"
  18. :close-on-click-modal="false"
  19. >
  20. <el-form ref="form" :model="diaLogForm" label-width="80px">
  21. <el-row :gutter="20">
  22. <el-col :span="24" :offset="0">
  23. <el-form-item label="产品名称">
  24. <el-select placeholder="选择名称" filterable @change="hanleName" v-model="diaLogForm.materialId">
  25. <el-option v-for="item in materialLis" :label="item.name" :value="item.id" :key="item.id"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="产品型号">
  29. <el-input v-model="diaLogForm.productModel"></el-input>
  30. </el-form-item>
  31. <el-form-item label="套机编码">
  32. <el-input v-model="diaLogForm.productNumber"></el-input>
  33. </el-form-item>
  34. <el-form-item label="产品体积">
  35. <el-input v-model="diaLogForm.productVolume"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. <el-row :gutter="20">
  40. <el-col :span="24" :offset="0">
  41. <el-row type="flex" justify="space-between">
  42. <el-col :span="20" type="flex">
  43. <el-form-item label="类型">
  44. <el-select v-model="diaLogForm.type" @change="hanleType" filterable placeholder="请选择类型">
  45. <el-option
  46. v-for="item in DistType"
  47. :key="item.dictCode"
  48. :label="item.dictValue"
  49. :value="item.dictCode"
  50. >
  51. </el-option>
  52. </el-select> </el-form-item
  53. ></el-col>
  54. <el-col :span="3" style="text-align: right">
  55. <el-button type="primary" @click="hanleAddData">+</el-button></el-col
  56. >
  57. </el-row>
  58. </el-col>
  59. </el-row>
  60. <el-row :gutter="20">
  61. <el-col :span="12" :offset="0" v-for="(item, index) in diaLogForm.items" :key="index">
  62. <div>
  63. <el-form-item label="编码">
  64. <el-select v-model="item.number" placeholder="请选择编码" filterable @change="hanleCode($event, index)">
  65. <el-option v-for="item in machineList" :key="item.id" :label="item.number" :value="item.id">
  66. </el-option>
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="名称" prop="">
  70. <el-input v-model="item.name" placeholder=""></el-input>
  71. </el-form-item>
  72. <el-form-item label="型号">
  73. <el-input v-model="item.model" placeholder=""></el-input>
  74. </el-form-item>
  75. <el-form-item label="体积">
  76. <el-input v-model="item.volume" placeholder=""></el-input>
  77. </el-form-item></div
  78. ></el-col>
  79. </el-row>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button @click="handleClose">取 消</el-button>
  83. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  84. </div>
  85. </el-dialog>
  86. </template-page>
  87. </template>
  88. <script>
  89. import TemplatePage from '@/components/template/template-page-1.vue'
  90. import import_mixin from '@/components/template/import_mixin.js'
  91. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  92. import Popu from '@/components/template/popu.vue'
  93. import { downloadFiles } from '@/utils/util'
  94. import {
  95. getDistList,
  96. getMachineLlist,
  97. getMaterialList,
  98. getProductAdd,
  99. getProductDel,
  100. getProductDetail,
  101. getProductEdit,
  102. getProductListV2,
  103. exportProductListV2
  104. } from '@/api/basic_data/material'
  105. export default {
  106. components: { TemplatePage, Popu },
  107. mixins: [import_mixin, add_callback_mixin],
  108. data() {
  109. return {
  110. visible: false,
  111. // 事件组合
  112. // 事件组合
  113. optionsEvensGroup: [
  114. [
  115. [
  116. {
  117. name: '新增',
  118. click: this.addOn(() => {
  119. this.showDialogForm = true
  120. this.type = 1
  121. this.hanleMachine()
  122. }),
  123. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  124. }
  125. ]
  126. ],
  127. [
  128. [
  129. {
  130. name: '批量删除',
  131. click: async () => {
  132. if (this.recordSelected.length === 0) {
  133. this.$message.error('请选择需要删除的数据')
  134. return
  135. }
  136. let ids = this.recordSelected.map(v => {
  137. return v.id
  138. })
  139. let params = { ids: ids.join() }
  140. await getProductDel(params)
  141. this.$refs.pageRef.refreshList()
  142. this.$message.success('批量删除成功')
  143. },
  144. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  145. }
  146. ]
  147. ]
  148. // [
  149. // [
  150. // {
  151. // name: '导入',
  152. // render: this.importButton(importCustomerPtV2)
  153. // }
  154. // ]
  155. // ],
  156. ],
  157. // 表格属性
  158. tableAttributes: {
  159. // 启用勾选列
  160. selectColumn: true
  161. }, // 关闭新增弹窗
  162. // 表格事件
  163. tableEvents: {
  164. 'selection-change': this.selectionChange
  165. },
  166. currentPage: 1, // 当前页码
  167. pageSize: 10, // 每页数量
  168. listTotal: 0, // 列表总数
  169. options: [
  170. {
  171. value: '选项1',
  172. label: '1'
  173. },
  174. {
  175. value: '选项2',
  176. label: '2'
  177. },
  178. {
  179. value: '选项3',
  180. label: '3'
  181. },
  182. {
  183. value: '选项4',
  184. label: '4'
  185. },
  186. {
  187. value: '选项5',
  188. label: '5'
  189. }
  190. ],
  191. diaLogForm: {
  192. adminCompanyId: null,
  193. productNumber: '',
  194. id: null,
  195. items: [
  196. {
  197. id: '',
  198. innerOutsideMachineId: '',
  199. machineConfigureId: '',
  200. parentId: '',
  201. model: '',
  202. name: '',
  203. number: '',
  204. type: '',
  205. volume: ''
  206. }
  207. ],
  208. materialId: null,
  209. productModel: '',
  210. productVolume: 0,
  211. type: ''
  212. },
  213. showDialogForm: false,
  214. dataList: [],
  215. screenForm: {
  216. innerName: '',
  217. innerNumber: '',
  218. innerType: '',
  219. name: '',
  220. number: '',
  221. outsideName: '',
  222. outsideNumber: '',
  223. outsideType: '',
  224. type: '',
  225. volume: ''
  226. },
  227. type: null,
  228. machineList: [],
  229. machinePei: {
  230. currentPage: 1,
  231. pageSize: 10,
  232. name: '',
  233. number: '',
  234. type: '',
  235. volume: ''
  236. },
  237. materialLis: {},
  238. typeList: [],
  239. DistType: [],
  240. isCollapse: true,
  241. machineConfigureId: ''
  242. }
  243. },
  244. created() {
  245. this.getMaterMacList()
  246. },
  247. methods: {
  248. // 列表请求函数
  249. getList(...p) {
  250. this.recordSelected = []
  251. return getProductListV2(...p)
  252. },
  253. // 列表导出函数
  254. exportList: exportProductListV2,
  255. // 表格列解析渲染数据更改
  256. columnParsing(item, defaultData) {
  257. return defaultData
  258. },
  259. // 监听勾选变化
  260. selectionChange(data) {
  261. this.recordSelected = data
  262. },
  263. operation() {
  264. return (h, { row, index, column }) => {
  265. return (
  266. <div class="operation-btns">
  267. {this.$checkBtnRole('edit', this.$route.meta.roles) ? (
  268. <el-button
  269. type="text"
  270. size="mini"
  271. class="textColor"
  272. onClick={() => {
  273. this.editFn(row.id, row, index)
  274. }}
  275. >
  276. 编辑
  277. </el-button>
  278. ) : null}
  279. {this.$checkBtnRole('del', this.$route.meta.roles) ? (
  280. <el-popconfirm
  281. confirm-button-text="好的"
  282. cancel-button-text="不用了"
  283. icon="el-icon-info"
  284. icon-color="red"
  285. title="内容确定删除吗?"
  286. onOnConfirm={() => this.hanleDelete(row.id)}
  287. >
  288. <el-button slot="reference" size="mini" type="text" class="textColor el-popover-left">
  289. 删除
  290. </el-button>
  291. </el-popconfirm>
  292. ) : null}
  293. </div>
  294. )
  295. }
  296. },
  297. handleClose() {
  298. this.addOff(() => {
  299. this.showDialogForm = false
  300. this.resetInfo()
  301. })()
  302. },
  303. hanleAddData() {
  304. this.diaLogForm.items.push({
  305. id: '',
  306. innerOutsideMachineId: '',
  307. machineConfigureId: '',
  308. parentId: '',
  309. model: '',
  310. name: '',
  311. number: '',
  312. type: '',
  313. volume: ''
  314. })
  315. },
  316. getMaterMacList() {
  317. const params = {
  318. pageNum: 1,
  319. pageSize: -1,
  320. keyword: ''
  321. }
  322. getMaterialList(params).then(res => {
  323. this.materialLis = res.data.records
  324. })
  325. const params2 = {
  326. pageNum: this.currentPage,
  327. pageSize: this.pageSize,
  328. keyword: ''
  329. }
  330. getMachineLlist(params2).then(res => {
  331. this.typeList = res.data.records
  332. })
  333. },
  334. hanleType(e) {
  335. console.log(e, this.DistType)
  336. this.getMachineLlist(e)
  337. },
  338. getMachineLlist(e) {
  339. let params2 = {
  340. pageNum: 1,
  341. pageSize: -1,
  342. model: this.machinePei.model,
  343. name: this.machinePei.name,
  344. number: this.machinePei.number,
  345. type: e,
  346. volume: this.machinePei.volume
  347. }
  348. getMachineLlist(params2).then(res => {
  349. this.machineList = res.data.records
  350. })
  351. },
  352. hanleCode(e, i) {
  353. console.log(e, 'code')
  354. this.machineList.find(l => {
  355. if (l.id == e) {
  356. this.$set(this.diaLogForm.items, i, {
  357. id: '',
  358. machineConfigureId: l.id,
  359. parentId: '',
  360. innerOutsideMachineId: l.id,
  361. model: l.model,
  362. name: l.name,
  363. number: l.number || '',
  364. type: l.type,
  365. volume: l.volume
  366. })
  367. }
  368. })
  369. },
  370. hanleName(e) {
  371. this.materialLis.find(k => {
  372. if (k.id == e) {
  373. this.diaLogForm.productModel = k.specification
  374. this.diaLogForm.productNumber = k.number
  375. this.diaLogForm.volume = k.volume
  376. }
  377. })
  378. },
  379. editFn(id, row, index) {
  380. console.log(row, '45465')
  381. let dateils = null
  382. this.diaLogForm = {
  383. ...row,
  384. items: [
  385. {
  386. id: '',
  387. machineConfigureId: row.id,
  388. parentId: '',
  389. innerOutsideMachineId: row.id,
  390. model: row.model,
  391. name: row.name,
  392. number: row.number || '',
  393. type: row.type,
  394. volume: row.volume
  395. }
  396. ]
  397. }
  398. getProductDetail({ id: id }).then(res => {
  399. dateils = res.data
  400. console.log(dateils)
  401. this.diaLogForm.materialId = dateils.materialId
  402. this.materialLis.length &&
  403. this.materialLis.find(k => {
  404. if (k.id == dateils.materialId) {
  405. console.log(k, '5555')
  406. this.diaLogForm.productModel = k.specification
  407. this.diaLogForm.productNumber = k.number
  408. this.diaLogForm.productVolume = k.volume
  409. }
  410. })
  411. getDistList({ sysDictEnum: 'MACHINE_CONFIGURE' }).then(disType => {
  412. this.DistType = disType.data
  413. })
  414. this.showDialogForm = true
  415. })
  416. },
  417. hanleInfo() {
  418. if (this.type === 1) {
  419. this.diaLogForm.id = null
  420. this.diaLogForm.adminCompanyId = null
  421. getProductAdd({ ...this.diaLogForm }).then(res => {
  422. this.$successMsg('保存成功')
  423. this.resetInfo()
  424. this.$refs.pageRef.refreshList()
  425. })
  426. } else if (this.type === 2) {
  427. const params = { ...this.diaLogForm }
  428. getProductEdit(params).then(res => {
  429. this.$successMsg('编辑成功')
  430. this.resetInfo()
  431. this.$refs.pageRef.refreshList()
  432. })
  433. }
  434. this.showDialogForm = false
  435. },
  436. hanleDelete(id) {
  437. getProductDel({ ids: id }).then(res => {
  438. this.$successMsg('删除成功')
  439. this.$refs.pageRef.refreshList()
  440. })
  441. },
  442. handleExport() {
  443. let screenData = {
  444. customerName: this.screenForm.customerName,
  445. freeDay: this.screenForm.freeDay,
  446. toll: this.screenForm.toll
  447. }
  448. downloadFiles('product-compose/export', screenData)
  449. },
  450. resetInfo() {
  451. this.diaLogForm = {
  452. id: null,
  453. composeNumber: '',
  454. id: '',
  455. items: [
  456. {
  457. id: '',
  458. innerOutsideMachineId: '',
  459. machineConfigureId: '',
  460. parentId: '',
  461. model: '',
  462. name: '',
  463. number: '',
  464. type: '',
  465. volume: ''
  466. }
  467. ],
  468. materialId: '',
  469. orgNumber: 0,
  470. productModel: '',
  471. productVolume: ''
  472. }
  473. },
  474. hanleMachine() {
  475. let params = {
  476. pageNum: 1,
  477. pageSize: -1,
  478. keyword: ''
  479. }
  480. getMaterialList(params).then(res => {
  481. this.materialLis = res.data.records
  482. })
  483. getDistList({ sysDictEnum: 'MACHINE_CONFIGURE' }).then(res => {
  484. console.log(res, 'type')
  485. this.DistType = res.data
  486. })
  487. }
  488. }
  489. }
  490. </script>
  491. <style lang="scss" scoped>
  492. ::v-deep .el-select {
  493. width: 100%;
  494. }
  495. </style>