user-edit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal width="1160px" :visible="visible" :append-to-body="true" :close-on-click-modal="true"
  4. custom-class="ele-dialog-form" :title="isUpdate ? '修改参数' : '添加参数'" @update:visible="updateVisible">
  5. <header-title title="基本信息"></header-title>
  6. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  7. <el-row>
  8. <el-col :span="8">
  9. <el-form-item label="产品名称:" prop="categoryName">
  10. <el-input @click.native="chooseProduct" v-model="form.categoryName" readonly />
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="8">
  14. <el-form-item label="产品编码:" prop="categoryCode">
  15. <el-input disabled v-model="form.categoryCode" placeholder="自动带入" />
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="8">
  19. <el-form-item label="型号:" prop="modelType">
  20. <el-input disabled v-model="form.modelType" placeholder="自动带入" />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="牌号:" prop="brandNum">
  25. <el-input disabled v-model="form.brandNum" placeholder="自动带入" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8">
  29. <el-form-item label="规格:" prop="specification">
  30. <el-input disabled v-model="form.specification" placeholder="自动带入" />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="8">
  34. <el-form-item label="生产版本:" prop="produceVersionId">
  35. <el-select v-model="form.produceVersionId" filterable placeholder="清选择">
  36. <el-option v-for="item in VersionList" :key="item.value" :label="item.label" :value="item.value">
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="8">
  42. <el-form-item label="成型剂:" prop="moldingAgent">
  43. <DictSelection dictName="成型剂类别" clearable filterable v-model="form.moldingAgent">
  44. </DictSelection>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="8">
  48. <el-form-item label="舟皿名称:" prop="palletName">
  49. <el-input @click.native="chooseMolding" v-model="form.palletName" />
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="8">
  53. <el-form-item label="舟皿编码:" prop="palletCode">
  54. <el-input disabled placeholder="自动带入" v-model="form.palletCode" />
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-form-item label="舟皿规格:" prop="palletSpecs">
  59. <el-input disabled placeholder="自动带入" v-model="form.palletSpecs" />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="24">
  63. <el-form-item label="加工要求:" prop="processingRequirement">
  64. <el-input v-model="form.processingRequirement" />
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="24">
  68. <el-form-item label="备注:" prop="remark">
  69. <el-input v-model="form.remark" />
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. <header-title title="产品参数"></header-title>
  74. <el-row>
  75. <div class="ele-body">
  76. <ele-pro-table ref="table" :datasource="datasource" :columns="columns">
  77. <!-- 表头工具栏 -->
  78. <template v-slot:toolbar>
  79. <el-button size="small" icon="el-icon-plus" class="ele-btn-icon" type="primary"
  80. @click.native="openParam">添加参数</el-button>
  81. </template>
  82. <!-- 默认值 -->
  83. <template v-slot:defaultValue="{ row }">
  84. <el-input v-if="row.textType == 1 || row.textType == 4" v-model="row.defaultValue"
  85. placeholder="请输入"></el-input>
  86. <el-select v-if="row.textType == 2" v-model="row.defaultValue" placeholder="请选择">
  87. <el-option label="TRUE" :value="'TRUE'" />
  88. <el-option label="FALSE" :value="'FALSE'" />
  89. </el-select>
  90. </template>
  91. <!-- 上限 -->
  92. <template v-slot:maxValue="{ row }">
  93. <el-input v-if="row.textType == 3" v-model="row.maxValue" placeholder="请输入"></el-input>
  94. </template>
  95. <!-- 下限 -->
  96. <template v-slot:minValue="{ row }">
  97. <el-input v-if="row.textType == 3" v-model="row.minValue" placeholder="请输入"></el-input>
  98. </template>
  99. <!-- 单位 -->
  100. <template v-slot:unitName="{ row }">
  101. <DictSelection v-if="row.textType != 2" dictName="工艺参数单位" clearable filterable v-model="row.unitName">
  102. </DictSelection>
  103. </template>
  104. <!-- 操作列 -->
  105. <template v-slot:action="{ row }">
  106. <el-popconfirm class="ele-action" title="确定要删除当前参数吗?" @confirm="remove(row)">
  107. <template v-slot:reference>
  108. <el-link type="danger" :underline="false" icon="el-icon-delete">
  109. 删除
  110. </el-link>
  111. </template>
  112. </el-popconfirm>
  113. </template>
  114. </ele-pro-table>
  115. </div>
  116. </el-row>
  117. <header-title title="添加工序"></header-title>
  118. </el-form>
  119. <template v-slot:footer>
  120. <el-button @click="updateVisible(false)">取消</el-button>
  121. <el-button type="primary" :loading="loading" @click="save">
  122. 保存
  123. </el-button>
  124. </template>
  125. <!-- 选择产品弹窗 -->
  126. <ProductModal ref="productRefs" @changeProduct='determineChoose' />
  127. <!-- 选择产品参数 -->
  128. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  129. <!-- 选择工序 -->
  130. <Process @chooseProcess="chooseProcess"></Process>
  131. </ele-modal>
  132. </template>
  133. <script>
  134. import parameter from '@/api/technology/productParam';
  135. import ProductModal from './ProductModal.vue';
  136. import Process from './process.vue'
  137. import ParamModal from './ParamModal.vue'
  138. import { deepClone } from '@/components/FormGenerator/utils/index';
  139. export default {
  140. components: {
  141. ProductModal,
  142. ParamModal,
  143. Process
  144. },
  145. props: {
  146. // 弹窗是否打开
  147. visible: Boolean,
  148. // 修改回显的数据
  149. data: Object
  150. },
  151. data() {
  152. const defaultForm = {
  153. id: null,
  154. code: '',
  155. name: '',
  156. moldingAgent: '',
  157. palletId: '',
  158. processingRequirement: '',
  159. remark: '',
  160. taskParam: [
  161. ],
  162. produceParam: []
  163. };
  164. return {
  165. defaultForm,
  166. // 表单数据
  167. form: { ...defaultForm },
  168. VersionList: [],
  169. // 表单验证规则
  170. rules: {
  171. categoryName: [
  172. { required: true, message: '请输入产品名称', trigger: 'blur' }
  173. ],
  174. code: [
  175. { required: true, message: '请输入工序编码', trigger: 'blur' }
  176. ],
  177. },
  178. // 提交状态
  179. loading: false,
  180. // 是否是修改
  181. isUpdate: false,
  182. tableData: [],
  183. removeList: [],
  184. // 表格列配置
  185. columns: [
  186. {
  187. prop: 'code',
  188. label: '参数编码',
  189. showOverflowTooltip: true,
  190. align: 'center',
  191. minWidth: 110
  192. },
  193. {
  194. prop: 'name',
  195. label: '参数名称',
  196. showOverflowTooltip: true,
  197. align: 'center',
  198. minWidth: 110
  199. },
  200. {
  201. align: 'center',
  202. prop: 'description',
  203. label: '文本描述',
  204. showOverflowTooltip: true,
  205. minWidth: 110
  206. },
  207. {
  208. prop: 'maxValue',
  209. slot: 'maxValue',
  210. label: '参数上限',
  211. align: 'center',
  212. },
  213. {
  214. prop: 'minValue',
  215. slot: 'minValue',
  216. label: '参数下限',
  217. align: 'center',
  218. },
  219. {
  220. prop: 'defaultValue',
  221. slot: 'defaultValue',
  222. label: '默认值',
  223. align: 'center',
  224. },
  225. {
  226. prop: 'unitName',
  227. slot: 'unitName',
  228. label: '参数单位',
  229. align: 'center',
  230. showOverflowTooltip: true
  231. },
  232. {
  233. columnKey: 'action',
  234. label: '操作',
  235. align: 'center',
  236. resizable: false,
  237. slot: 'action',
  238. showOverflowTooltip: true
  239. }
  240. ],
  241. };
  242. },
  243. computed: {
  244. // 是否开启响应式布局
  245. styleResponsive() {
  246. return this.$store.state.theme.styleResponsive;
  247. }
  248. },
  249. methods: {
  250. chooseProduct() {
  251. this.$refs.productRefs.open(this.form, '选择产品', '9')
  252. },
  253. chooseMolding() {
  254. this.$refs.productRefs.open(this.form, '选择舟皿', '8')
  255. },
  256. determineChoose(title, row) {
  257. if (title == '选择产品') {
  258. this.$set(this.form, 'categoryName', row.name)
  259. this.$set(this.form, 'categoryId', row.id)
  260. this.$set(this.form, 'categoryCode', row.code)
  261. this.$set(this.form, 'modelType', row.name)
  262. this.$set(this.form, 'brandNum', row.brandNum)
  263. this.$set(this.form, 'specification', row.specification)
  264. } else if (title == '选择舟皿') {
  265. this.$set(this.form, 'palletName', row.name)
  266. this.$set(this.form, 'palletId', row.id)
  267. this.$set(this.form, 'palletCode', row.code)
  268. this.$set(this.form, 'palletSpecs', row.specification)
  269. }
  270. },
  271. openParam() {
  272. this.tableData = this.$refs.table.getData()
  273. this.$refs.paramRefs.open(this.tableData)
  274. },
  275. chooseModal(data) {
  276. this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
  277. let _arr = JSON.stringify([...data, ...this.$refs.table.getData()])
  278. this.$set(this.form, 'taskParam', _arr)
  279. },
  280. /* 表格数据源 */
  281. datasource({ page, limit, where }) {
  282. return []
  283. },
  284. remove(row) {
  285. const data = this.$refs.table.getData() ?? [];
  286. if (row.id) {
  287. this.removeList.push(row.id);
  288. this.$refs.table.setData(data.filter((d) => d.id !== row.id));
  289. } else {
  290. this.$refs.table.setData(
  291. data.filter((d) => d.paramId !== row.paramId)
  292. );
  293. }
  294. },
  295. /* 保存编辑 */
  296. save() {
  297. this.$refs.form.validate((valid) => {
  298. if (!valid) {
  299. return false;
  300. }
  301. this.loading = true;
  302. if (!this.isUpdate) {
  303. delete this.form.id;
  304. }
  305. const saveOrUpdate = this.isUpdate
  306. ? parameter.update
  307. : parameter.save;
  308. saveOrUpdate(this.form)
  309. .then((msg) => {
  310. this.loading = false;
  311. this.form = {};
  312. const info = this.isUpdate ? '修改成功' : '新增成功'
  313. this.$message.success(info);
  314. this.updateVisible(false);
  315. this.$emit('done');
  316. })
  317. .catch((e) => {
  318. this.loading = false;
  319. // this.$message.error(e.message);
  320. });
  321. });
  322. },
  323. /* 更新visible */
  324. updateVisible(value) {
  325. this.$emit('update:visible', value);
  326. },
  327. async getParamList() {
  328. const res = await parameter.list({
  329. pageNum: 1,
  330. size: 100
  331. });
  332. this.paramList = res.list
  333. console.log(this.paramList)
  334. },
  335. chooseProcess(data) {
  336. let _arr = JSON.stringify(data)
  337. this.$set(this.form, 'produceParam', _arr)
  338. },
  339. },
  340. watch: {
  341. async visible(visible) {
  342. if (visible) {
  343. this.getParamList()
  344. if (this.data) {
  345. const res = await parameter.getById(this.data.id);
  346. this.$util.assignObject(this.form, {
  347. ...res
  348. });
  349. this.isUpdate = true;
  350. } else {
  351. this.isUpdate = false;
  352. }
  353. } else {
  354. this.$refs.form.clearValidate();
  355. this.form = { ...this.defaultForm };
  356. }
  357. }
  358. }
  359. };
  360. </script>