user-edit.vue 13 KB

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