user-edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <ele-modal
  3. width="1160px"
  4. :visible="visible"
  5. v-if="visible"
  6. :append-to-body="true"
  7. :close-on-click-modal="false"
  8. custom-class="ele-dialog-form"
  9. :title="isUpdate ? '修改参数' : '添加参数'"
  10. @update:visible="updateVisible"
  11. :maxable="true"
  12. >
  13. <header-title title="基本信息"></header-title>
  14. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  15. <el-row>
  16. <el-col :span="8">
  17. <el-form-item label="产品名称:" prop="categoryName">
  18. <el-input
  19. @click.native="chooseProduct"
  20. v-model="form.categoryName"
  21. :disabled="isProduct"
  22. readonly
  23. />
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="产品编码:" prop="categoryCode">
  28. <el-input
  29. disabled
  30. v-model="form.categoryCode"
  31. placeholder="自动带入"
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8">
  36. <el-form-item label="牌号:" prop="categoryBrandNum">
  37. <el-input
  38. disabled
  39. v-model="form.categoryBrandNum"
  40. placeholder="自动带入"
  41. />
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="8">
  45. <el-form-item label="型号:" prop="categoryModelType">
  46. <el-input
  47. disabled
  48. v-model="form.categoryModelType"
  49. placeholder="自动带入"
  50. />
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="规格:" prop="categorySpecification">
  55. <el-input
  56. disabled
  57. v-model="form.categorySpecification"
  58. placeholder="自动带入"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-form-item label="工艺类型:" prop="produceVersionId">
  64. <el-select
  65. v-model="form.produceVersionId"
  66. filterable
  67. placeholder="请选择"
  68. :style="{ width: '100%' }"
  69. >
  70. <el-option
  71. v-for="item in versionList"
  72. :key="item.id"
  73. :label="item.code + '-' + item.name"
  74. :value="item.id"
  75. >
  76. </el-option>
  77. </el-select>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item label="成型剂:" prop="moldingAgent">
  82. <DictSelection
  83. dictName="成型剂类别"
  84. clearable
  85. filterable
  86. v-model="form.moldingAgent"
  87. >
  88. </DictSelection>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="舟皿名称:" prop="palletName">
  93. <el-input @click.native="chooseMolding" v-model="form.palletName" />
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="8">
  97. <el-form-item label="舟皿编码:" prop="palletCode">
  98. <el-input
  99. disabled
  100. placeholder="自动带入"
  101. v-model="form.palletCode"
  102. />
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8">
  106. <el-form-item label="舟血型号:" prop="palletModelType">
  107. <el-input
  108. disabled
  109. placeholder="自动带入"
  110. v-model="form.palletModelType"
  111. />
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8">
  115. <el-form-item label="舟皿规格:" prop="palletSpecification">
  116. <el-input
  117. disabled
  118. placeholder="自动带入"
  119. v-model="form.palletSpecification"
  120. />
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="24">
  124. <el-form-item label="加工要求:" prop="processingRequirement">
  125. <el-input v-model="form.processingRequirement" />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="24">
  129. <el-form-item label="备注:" prop="remark">
  130. <el-input v-model="form.remark" />
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. <header-title title="产品参数"></header-title>
  135. <el-row>
  136. <div class="ele-body">
  137. <ele-pro-table
  138. ref="table"
  139. :datasource="tableList"
  140. :columns="columns"
  141. row-key="id"
  142. >
  143. <!-- 表头工具栏 -->
  144. <template v-slot:toolbar>
  145. <el-button
  146. size="small"
  147. icon="el-icon-plus"
  148. class="ele-btn-icon"
  149. type="primary"
  150. @click.native="openParam"
  151. >添加参数</el-button
  152. >
  153. </template>
  154. <template v-slot:sort="{ row }">
  155. <el-input v-model="row.sort"></el-input>
  156. </template>
  157. <!-- 默认值 -->
  158. <template v-slot:defaultValue="{ row }">
  159. <el-input
  160. v-if="
  161. row.textType == 1 ||
  162. row.textType == 4 ||
  163. row.textType == 3 ||
  164. row.textType == 5
  165. "
  166. v-model="row.defaultValue"
  167. placeholder="请输入"
  168. ></el-input>
  169. <el-select
  170. v-if="row.textType == 2"
  171. v-model="row.defaultValue"
  172. placeholder="请选择"
  173. >
  174. <el-option label="TRUE" :value="'TRUE'" />
  175. <el-option label="FALSE" :value="'FALSE'" />
  176. </el-select>
  177. </template>
  178. <!-- 上限 -->
  179. <template v-slot:maxValue="{ row }">
  180. <el-input
  181. v-if="row.textType == 3"
  182. v-model="row.maxValue"
  183. placeholder="请输入"
  184. ></el-input>
  185. </template>
  186. <!-- 下限 -->
  187. <template v-slot:minValue="{ row }">
  188. <el-input
  189. v-if="row.textType == 3"
  190. v-model="row.minValue"
  191. placeholder="请输入"
  192. ></el-input>
  193. </template>
  194. <!-- 单位 -->
  195. <template v-slot:unitName="{ row }">
  196. <DictSelection
  197. v-if="row.textType != 2 && row.textType != 5"
  198. dictName="工艺参数单位"
  199. clearable
  200. filterable
  201. v-model="row.unitName"
  202. >
  203. </DictSelection>
  204. <span v-if="row.textType == 5"> h(小时)</span>
  205. </template>
  206. <!-- 操作列 -->
  207. <template v-slot:action="{ row }">
  208. <el-popconfirm
  209. class="ele-action"
  210. title="确定要删除当前参数吗?"
  211. @confirm="remove(row)"
  212. >
  213. <template v-slot:reference>
  214. <el-link
  215. type="danger"
  216. :underline="false"
  217. icon="el-icon-delete"
  218. >
  219. 删除
  220. </el-link>
  221. </template>
  222. </el-popconfirm>
  223. </template>
  224. </ele-pro-table>
  225. </div>
  226. </el-row>
  227. <!-- <header-title title="添加工序"></header-title> -->
  228. </el-form>
  229. <template v-slot:footer>
  230. <el-button @click="updateVisible(false)">取消</el-button>
  231. <el-button type="primary" :loading="loading" @click="save">
  232. 保存
  233. </el-button>
  234. </template>
  235. <!-- 选择产品弹窗 -->
  236. <ProductModal ref="productRefs" @changeProduct="determineChoose" />
  237. <!-- 选择产品参数 -->
  238. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  239. <!-- 选择工序 -->
  240. <!-- <Process @chooseProcess="chooseProcess" :taskParam="taskParam"></Process> -->
  241. </ele-modal>
  242. </template>
  243. <script>
  244. import parameter from '@/api/technology/productParam';
  245. import ProductModal from './ProductModal.vue';
  246. import Process from './process.vue';
  247. import ParamModal from './ParamModal.vue';
  248. import { pageList } from '@/api/technology/version/version.js';
  249. import { log } from 'bpmn-js-token-simulation';
  250. export default {
  251. components: {
  252. ProductModal,
  253. ParamModal,
  254. Process
  255. },
  256. props: {
  257. // 弹窗是否打开
  258. visible: Boolean,
  259. // 修改回显的数据
  260. data: Object,
  261. paramData: Object
  262. },
  263. data() {
  264. const defaultForm = {
  265. id: null,
  266. categoryId: '',
  267. categoryName: '',
  268. categoryCode: '',
  269. categoryModelType: '',
  270. categoryBrandNum: '',
  271. categorySpecification: '',
  272. produceVersionId: '',
  273. moldingAgent: '',
  274. palletId: null,
  275. palletName: '',
  276. palletCode: '',
  277. palletSpecification: '',
  278. palletModelType: '',
  279. processingRequirement: '',
  280. remark: '',
  281. taskParam: [],
  282. produceParam: []
  283. };
  284. return {
  285. defaultForm,
  286. // 表单数据
  287. form: { ...defaultForm },
  288. versionList: [],
  289. // 表单验证规则
  290. rules: {
  291. categoryName: [
  292. { required: true, message: '请输入产品名称', trigger: 'blur' }
  293. ],
  294. code: [{ required: true, message: '请输入工序编码', trigger: 'blur' }]
  295. },
  296. // 提交状态
  297. loading: false,
  298. // 是否是修改
  299. isUpdate: false,
  300. tableData: [],
  301. removeList: [],
  302. taskParam: [],
  303. // 表格列配置
  304. columns: [
  305. {
  306. prop: 'sort',
  307. slot: 'sort',
  308. label: '排序',
  309. minWidth: 60
  310. },
  311. {
  312. prop: 'code',
  313. label: '参数编码',
  314. showOverflowTooltip: true,
  315. align: 'center',
  316. minWidth: 110
  317. },
  318. {
  319. prop: 'name',
  320. label: '参数名称',
  321. showOverflowTooltip: true,
  322. align: 'center',
  323. minWidth: 110
  324. },
  325. {
  326. align: 'center',
  327. prop: 'description',
  328. label: '文本描述',
  329. showOverflowTooltip: true,
  330. minWidth: 110
  331. },
  332. {
  333. prop: 'maxValue',
  334. slot: 'maxValue',
  335. label: '参数上限',
  336. align: 'center'
  337. },
  338. {
  339. prop: 'minValue',
  340. slot: 'minValue',
  341. label: '参数下限',
  342. align: 'center'
  343. },
  344. {
  345. prop: 'defaultValue',
  346. slot: 'defaultValue',
  347. label: '默认值',
  348. align: 'center'
  349. },
  350. {
  351. prop: 'unitName',
  352. slot: 'unitName',
  353. label: '参数单位',
  354. align: 'center',
  355. showOverflowTooltip: true
  356. },
  357. {
  358. columnKey: 'action',
  359. label: '操作',
  360. align: 'center',
  361. resizable: false,
  362. slot: 'action',
  363. showOverflowTooltip: true
  364. }
  365. ],
  366. isProduct: false, // 判断是否是产品
  367. isProductUpdate: null, // 1 新增, 2编辑
  368. tableList: []
  369. };
  370. },
  371. computed: {
  372. // 是否开启响应式布局
  373. styleResponsive() {
  374. return this.$store.state.theme.styleResponsive;
  375. }
  376. },
  377. methods: {
  378. chooseProduct() {
  379. this.$refs.productRefs.open(this.form, '选择产品', '9');
  380. },
  381. chooseMolding() {
  382. this.$refs.productRefs.open(this.form, '选择舟皿', '8');
  383. },
  384. determineChoose(title, row) {
  385. if (title == '选择产品') {
  386. this.$set(this.form, 'categoryName', row.name);
  387. this.$set(this.form, 'categoryId', row.id);
  388. this.$set(this.form, 'categoryCode', row.code);
  389. this.$set(this.form, 'categoryModelType', row.modelType);
  390. this.$set(this.form, 'categoryBrandNum', row.brandNum);
  391. this.$set(this.form, 'specification', row.specification);
  392. } else if (title == '选择舟皿') {
  393. this.$set(this.form, 'palletName', row.name);
  394. this.$set(this.form, 'palletId', row.id);
  395. this.$set(this.form, 'palletCode', row.code);
  396. this.$set(this.form, 'palletSpecs', row.specification);
  397. this.$set(this.form, 'ModelType', row.modelType);
  398. }
  399. },
  400. openParam() {
  401. this.tableData = this.$refs.table.getData();
  402. this.$refs.paramRefs.open(this.tableData);
  403. },
  404. chooseModal(data) {
  405. this.removeList = this.removeList.filter(
  406. (id) => !data.some((d) => d.id === id)
  407. );
  408. this.tableList = [...data, ...this.$refs.table.getData()];
  409. this.$set(this.form, 'produceParam', this.tableList);
  410. },
  411. remove(row) {
  412. console.log('row', row);
  413. console.log('this.tableList', this.tableList);
  414. if (row.id) {
  415. this.removeList.push(row.id);
  416. this.tableList = this.tableList.filter((d) => d.id != row.id);
  417. } else {
  418. this.tableList = this.tableList.filter(
  419. (d) => d.paramId != row.paramId
  420. );
  421. }
  422. },
  423. /* 保存编辑 */
  424. save() {
  425. this.$refs.form.validate((valid) => {
  426. if (!valid) {
  427. return false;
  428. }
  429. this.loading = true;
  430. if (!this.isUpdate && this.isProductUpdate == null) {
  431. delete this.form.id;
  432. }
  433. let saveOrUpdate = this.isUpdate ? parameter.update : parameter.save;
  434. if (this.isProductUpdate != null) {
  435. saveOrUpdate =
  436. this.isProductUpdate == 2 ? parameter.update : parameter.save;
  437. }
  438. if (this.removeList.length > 0) {
  439. this.form['removeList'] = this.removeList;
  440. }
  441. saveOrUpdate(this.form)
  442. .then((msg) => {
  443. this.loading = false;
  444. this.form = {};
  445. this.removeList = [];
  446. this.$message.success(msg);
  447. this.updateVisible(false);
  448. this.$emit('done');
  449. })
  450. .catch((e) => {
  451. this.loading = false;
  452. // this.$message.error(e.message);
  453. });
  454. });
  455. },
  456. /* 更新visible */
  457. updateVisible(value) {
  458. this.$emit('update:visible', value);
  459. },
  460. async getParamList() {
  461. const res = await parameter.list({
  462. pageNum: 1,
  463. size: 100
  464. });
  465. this.paramList = res.list;
  466. },
  467. async getVersionList() {
  468. const res = await pageList({
  469. pageNum: 1,
  470. size: 100
  471. });
  472. this.versionList = res.list;
  473. },
  474. chooseProcess(data) {
  475. this.$set(this.form, 'taskParam', data);
  476. }
  477. },
  478. watch: {
  479. async visible(visible) {
  480. if (visible) {
  481. this.getParamList();
  482. this.getVersionList();
  483. // 产品工艺参数
  484. if (this.data) {
  485. const res = await parameter.getById(this.data.id);
  486. this.$util.assignObject(this.form, {
  487. ...res
  488. });
  489. this.tableList = res.produceParam;
  490. this.taskParam = res.taskParam;
  491. this.isUpdate = true;
  492. } else if (this.paramData) {
  493. this.isProduct = true;
  494. let param = {
  495. categoryId: this.paramData.id,
  496. categoryName: this.paramData.name,
  497. categoryCode: this.paramData.code,
  498. categoryModelType: this.paramData.modelType,
  499. categoryBrandNum: this.paramData.brandNum,
  500. categorySpecification: this.paramData.specification
  501. };
  502. const res = await parameter.getCategoryParam(this.paramData.id);
  503. if (res) {
  504. this.isProductUpdate = 2;
  505. this.$util.assignObject(this.form, {
  506. ...res
  507. });
  508. this.tableList = res.produceParam;
  509. this.taskParam = res.taskParam;
  510. } else {
  511. this.$util.assignObject(this.form, {
  512. ...param
  513. });
  514. this.isProductUpdate = 1;
  515. }
  516. } else {
  517. this.isUpdate = false;
  518. }
  519. } else {
  520. this.$refs.form.clearValidate();
  521. this.form = { ...this.defaultForm };
  522. }
  523. }
  524. }
  525. };
  526. </script>