send-order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <!-- 字典编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. width="960px"
  5. :maxable="true"
  6. :visible="visible"
  7. :close-on-click-modal="true"
  8. title="派单"
  9. @update:visible="updateVisible"
  10. >
  11. <HeaderTitle title="选择生产设备" size="16px"></HeaderTitle>
  12. <el-form
  13. ref="form"
  14. :model="form"
  15. :rules="rules"
  16. label-width="85px"
  17. style="margin-bottom: 10px"
  18. >
  19. <el-row>
  20. <el-col :span="8">
  21. <el-form-item label="字典名称:" prop="name">
  22. <el-select
  23. v-model="form.name"
  24. placeholder="请选择"
  25. @change="OneChange(1)"
  26. >
  27. <el-option
  28. v-for="item in options"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value"
  32. >
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8">
  38. <el-form-item label="字典值:" prop="code">
  39. <el-select
  40. v-model="form.name1"
  41. placeholder="请选择"
  42. @change="OneChange(2)"
  43. >
  44. <el-option
  45. v-for="item in options"
  46. :key="item.label"
  47. :label="item.label"
  48. :value="item.value"
  49. >
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="8">
  55. <el-form-item label="应用类型:" prop="appType">
  56. <el-select v-model="form.name2" placeholder="请选择">
  57. <el-option
  58. v-for="item in options"
  59. :key="item.name"
  60. :label="item.label"
  61. :value="item.value"
  62. >
  63. </el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. </el-row>
  68. </el-form>
  69. <HeaderTitle title="生产基本信息" size="16px"></HeaderTitle>
  70. <el-form
  71. ref="form"
  72. :model="form"
  73. :rules="rules"
  74. label-width="110px"
  75. style="margin-bottom: 10px"
  76. >
  77. <el-row>
  78. <el-col :span="8">
  79. <el-form-item label="产品分类:"> 1111 </el-form-item>
  80. </el-col>
  81. <el-col :span="8">
  82. <el-form-item label="生产版本:"> 2222 </el-form-item>
  83. </el-col>
  84. <el-col :span="8">
  85. <el-form-item label="交货日期:"> 3333 </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="产品牌号:"> 3333 </el-form-item>
  89. </el-col>
  90. <el-col :span="8">
  91. <el-form-item label="产品型号:"> 3333 </el-form-item>
  92. </el-col>
  93. <el-col :span="8">
  94. <el-form-item label="生产数量:"> 3333 </el-form-item>
  95. </el-col>
  96. <el-col :span="8">
  97. <el-form-item label="物料(产品)编码:"> 3333 </el-form-item>
  98. </el-col>
  99. <el-col :span="8">
  100. <el-form-item label="物料(产品)名称:"> 3333 </el-form-item>
  101. </el-col>
  102. <el-col :span="8">
  103. <el-form-item label="生产工单号:"> 3333 </el-form-item>
  104. </el-col>
  105. <el-col :span="8">
  106. <el-form-item label="销售单号:"> 3333 </el-form-item>
  107. </el-col>
  108. <el-col :span="8">
  109. <el-form-item label="计划单号:"> 3333 </el-form-item>
  110. </el-col>
  111. </el-row>
  112. </el-form>
  113. <HeaderTitle title="当班人员信息" size="16px"></HeaderTitle>
  114. <el-table
  115. :data="tableData"
  116. border
  117. style="width: 100%"
  118. @selection-change="handleSelectionChange"
  119. >
  120. <el-table-column prop="code" label="字典项编码">
  121. <template slot-scope="scope">
  122. <el-input
  123. @blur="checkedValue(scope.row.code)"
  124. v-model="scope.row.code"
  125. placeholder=""
  126. ></el-input>
  127. </template>
  128. </el-table-column>
  129. <el-table-column prop="name" label="字典项名称">
  130. <template slot-scope="scope">
  131. <el-input v-model="scope.row.name" placeholder=""></el-input>
  132. </template>
  133. </el-table-column>
  134. <el-table-column prop="sort" label="排序">
  135. <template slot-scope="scope">
  136. <el-input
  137. v-model="scope.row.sort"
  138. @input="
  139. scope.row.sort = String(scope.row.sort).replace(/[^\d]/g, '')
  140. "
  141. ></el-input>
  142. </template>
  143. </el-table-column>
  144. <el-table-column prop="enable" label="启用">
  145. <template slot-scope="scope">
  146. <el-radio-group v-model="scope.row.enable">
  147. <el-radio :label="1">是</el-radio>
  148. <el-radio :label="0">否</el-radio>
  149. </el-radio-group>
  150. </template>
  151. </el-table-column>
  152. <el-table-column align="center" label="操作">
  153. <template slot-scope="scope">
  154. <el-popconfirm
  155. class="ele-action"
  156. title="确定要删除此字典项吗?"
  157. @confirm="removeArr(scope)"
  158. >
  159. <template v-slot:reference>
  160. <el-link type="danger" :underline="false" icon="el-icon-delete">
  161. 删除
  162. </el-link>
  163. </template>
  164. </el-popconfirm>
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. <template v-slot:footer>
  169. <el-button @click="updateVisible(false)">取消</el-button>
  170. <el-button type="primary" :loading="loading" @click="save">
  171. 保存
  172. </el-button>
  173. </template>
  174. </ele-modal>
  175. </template>
  176. <script>
  177. import { addDictionary, updateDictionary } from '@/api/system/dictionary';
  178. import {
  179. pageDictionaryData,
  180. removeDictionaryData,
  181. removeDictionaryDataBatch
  182. } from '@/api/system/dictionary-data';
  183. export default {
  184. props: {
  185. // 弹窗是否打开
  186. visible: Boolean,
  187. // 修改回显的数据
  188. id: String | Number
  189. },
  190. data() {
  191. const defaultForm = {
  192. name: '',
  193. name1: '',
  194. name2: '',
  195. code: '',
  196. appType: 1,
  197. enable: 1,
  198. remark: '',
  199. dictStaticSubmitPOList: []
  200. };
  201. return {
  202. defaultForm,
  203. // 表单数据
  204. form: { ...defaultForm },
  205. // form: {
  206. // name: '',
  207. // code: '',
  208. // appType: 1,
  209. // enable: 1,
  210. // remark: ''
  211. // },
  212. // 表单验证规则
  213. rules: {
  214. name: [
  215. {
  216. required: true,
  217. message: '请输入字典名称',
  218. trigger: 'blur'
  219. }
  220. ],
  221. code: [
  222. {
  223. required: true,
  224. message: '请输入字典值',
  225. trigger: 'blur'
  226. }
  227. ],
  228. appType: [
  229. {
  230. required: true,
  231. message: '请选择应用类型',
  232. trigger: 'blur'
  233. }
  234. ],
  235. enable: [
  236. {
  237. required: true,
  238. message: '请选择是否启用',
  239. trigger: 'blur'
  240. }
  241. ],
  242. sort: [
  243. {
  244. required: true,
  245. message: '请输入排序号',
  246. trigger: 'blur'
  247. }
  248. ]
  249. },
  250. options: [
  251. { value: 1, label: '车间1', name: 11 },
  252. { value: 2, label: '车间2', name: 12 },
  253. { value: 3, label: '车间3', name: 13 },
  254. { value: 4, label: '车间4', name: 14 }
  255. ],
  256. // 表格列配置
  257. columns: [
  258. {
  259. columnKey: 'selection',
  260. type: 'selection',
  261. width: 45,
  262. align: 'center'
  263. },
  264. {
  265. columnKey: 'index',
  266. type: 'index',
  267. width: 45,
  268. align: 'center',
  269. showOverflowTooltip: true
  270. },
  271. {
  272. prop: 'code',
  273. label: '字典编码',
  274. showOverflowTooltip: true
  275. },
  276. {
  277. prop: 'name',
  278. label: '字典名称',
  279. showOverflowTooltip: true
  280. },
  281. // {
  282. // prop: 'appType',
  283. // label: '字典类型',
  284. // showOverflowTooltip: true,
  285. // minWidth: 110
  286. // },
  287. {
  288. prop: 'appType',
  289. label: '应用类型',
  290. showOverflowTooltip: true
  291. },
  292. {
  293. prop: 'remark',
  294. label: '描述',
  295. showOverflowTooltip: true
  296. },
  297. {
  298. prop: 'createTime',
  299. label: '创建时间',
  300. showOverflowTooltip: true,
  301. minWidth: 110,
  302. formatter: (_row, _column, cellValue) => {
  303. return this.$util.toDateString(cellValue);
  304. }
  305. },
  306. {
  307. columnKey: 'action',
  308. label: '操作',
  309. width: 130,
  310. align: 'center',
  311. resizable: false,
  312. slot: 'action',
  313. showOverflowTooltip: true
  314. }
  315. ],
  316. tableData: [],
  317. // 表格选中数据
  318. selection: [],
  319. datasource: {
  320. list: []
  321. },
  322. // 提交状态
  323. loading: false,
  324. // 是否是修改
  325. isUpdate: false,
  326. delectId: 1
  327. };
  328. },
  329. created() {},
  330. methods: {
  331. OneChange(val) {
  332. if (val == 1) {
  333. this.form.name1 = '';
  334. this.form.name2 = '';
  335. } else if (val == 2) {
  336. this.form.name2 = '';
  337. }
  338. },
  339. pushArr() {
  340. this.form.dictStaticSubmitPOList.push({
  341. code: '',
  342. enable: 1,
  343. name: '',
  344. sort: '',
  345. delectId: this.delectId
  346. });
  347. this.delectId = this.delectId + 1;
  348. this.filterArr();
  349. },
  350. //
  351. checkedValue(val) {
  352. console.log(val);
  353. },
  354. removeArr(row) {
  355. console.log(row);
  356. if (row.row.id) {
  357. this.form.dictStaticSubmitPOList.forEach((item) => {
  358. if (item.id === row.row.id) {
  359. item.deleted = 1;
  360. }
  361. });
  362. this.filterArr();
  363. } else {
  364. let index = this.form.dictStaticSubmitPOList.findIndex(
  365. (item) => item.delectId === row.row.delectId
  366. );
  367. console.log(index);
  368. this.form.dictStaticSubmitPOList.splice(index, 1); // 在数组的指定位置移除对应的元素。 返回移除的
  369. this.filterArr();
  370. }
  371. // let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
  372. // if (falg) {
  373. // this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
  374. // this.filterArr();
  375. // } else {
  376. // this.form.dictStaticSubmitPOList.splice(row.$index, 1);
  377. // this.filterArr();
  378. // }
  379. },
  380. handleSelectionChange() {},
  381. /* 保存编辑 */
  382. save() {
  383. this.$refs.form.validate((valid) => {
  384. if (!valid) {
  385. return false;
  386. }
  387. let falg = this.form.dictStaticSubmitPOList.some(
  388. (item, index) => item.code.length === 0
  389. );
  390. if (falg) {
  391. this.$message({
  392. message: '字典项编码不能为空',
  393. type: 'warning'
  394. });
  395. return;
  396. }
  397. this.form.dictStaticSubmitPOList.forEach((item, index) => {
  398. if (item.delectId) {
  399. delete item.delectId;
  400. }
  401. });
  402. this.loading = true;
  403. const saveOrUpdate = this.isUpdate ? updateDictionary : addDictionary;
  404. saveOrUpdate(this.form)
  405. .then((msg) => {
  406. this.loading = false;
  407. this.$message.success(msg);
  408. this.updateVisible(false);
  409. this.$emit('done');
  410. })
  411. .catch((e) => {
  412. this.loading = false;
  413. // // this.$message.error(e.message);
  414. });
  415. });
  416. },
  417. filterArr() {
  418. this.tableData = this.form.dictStaticSubmitPOList.filter(
  419. (item) => item.deleted !== 1
  420. );
  421. },
  422. /* 更新visible */
  423. updateVisible(value) {
  424. this.$emit('update:visible', value);
  425. },
  426. getDetail() {
  427. // const res = await pageDictionaryData(this.id);
  428. // this.form = res.data.dictInfoVO;
  429. // this.form.dictStaticSubmitPOList = res.data.dictStaticVOList;
  430. // if (this.form.dictStaticSubmitPOList.length > 0) {
  431. // this.filterArr();
  432. // } else {
  433. // this.tableTata = [];
  434. // }
  435. }
  436. },
  437. watch: {
  438. visible(visible) {
  439. if (visible) {
  440. if (this.id) {
  441. // this.$util.assignObject(this.form, this.data);
  442. this.isUpdate = true;
  443. this.getDetail();
  444. } else {
  445. this.isUpdate = false;
  446. }
  447. } else {
  448. this.$refs.form.clearValidate();
  449. this.form = { ...this.defaultForm };
  450. this.form.dictStaticSubmitPOList = []; // clear the list of the dictionary static push button. 描述变化的字段不会在push后
  451. this.tableData = []; // clear the list of the dictionary static push button. 描述变化的字段不会在push后。
  452. }
  453. }
  454. }
  455. };
  456. </script>
  457. <style lang="scss" scoped>
  458. .divider {
  459. margin-bottom: 20px;
  460. .title {
  461. display: flex;
  462. align-items: center;
  463. margin-bottom: 10px;
  464. .ele-bg-primary {
  465. width: 8px;
  466. height: 20px;
  467. margin-right: 10px;
  468. }
  469. .action {
  470. flex: 1;
  471. display: flex;
  472. justify-content: flex-end;
  473. }
  474. span {
  475. font-size: 20px;
  476. }
  477. }
  478. }
  479. </style>