detail.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <el-form
  5. label-width="120px"
  6. ref="manageForm"
  7. :model="form"
  8. :rules="rules"
  9. >
  10. <headerTitle title="基本信息">
  11. <el-button @click="cancel">返回</el-button>
  12. <el-button type="primary" @click="submit" :loading="loading"
  13. >保存
  14. </el-button>
  15. </headerTitle>
  16. <el-row :gutter="24">
  17. <el-col :span="8">
  18. <el-form-item label="分类" prop="categoryLevelName">
  19. <el-input
  20. v-model="form.categoryLevelName"
  21. @click.native="openCategory"
  22. />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="8" v-if="ruleCode == '自定义'" key="1">
  26. <el-form-item label="编码" prop="code">
  27. <el-input
  28. v-model="form.code"
  29. readonly
  30. @click.native="openCode"
  31. :disabled="status == 0"
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8" v-else key="2">
  36. <el-form-item label="编码" prop="code">
  37. <el-input v-model="form.code" :disabled="status == 0" />
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="8">
  41. <el-form-item label="名称" prop="name">
  42. <el-input v-model="form.name" />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="8">
  46. <el-form-item label="图号/件号" prop="imgCode">
  47. <el-input v-model="form.imgCode" />
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="8">
  51. <el-form-item label="生产类型" prop="produceType">
  52. <el-select
  53. style="width: 100%"
  54. v-model="form.produceType"
  55. filterable
  56. multiple
  57. >
  58. <el-option
  59. v-for="item in dictList"
  60. :key="item.value"
  61. :value="item.value"
  62. :label="item.label"
  63. ></el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col
  68. :span="8"
  69. v-if="[1, 23, 9, 28].includes(Number(categoryLevelPathId))"
  70. >
  71. <el-form-item label="加工类型" prop="isConsumable">
  72. <el-select
  73. v-model="form.isConsumable"
  74. size="small"
  75. style="width: 100%"
  76. >
  77. <el-option :value="1" label="批量"></el-option>
  78. <el-option :value="0" label="单件"></el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8">
  83. <el-form-item label="牌号" prop="brandNum">
  84. <el-input v-model="form.brandNum" />
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="型号" prop="modelType">
  89. <el-input v-model="form.modelType" />
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8">
  93. <el-form-item label="规格" prop="specification">
  94. <el-input v-model="form.specification" />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-form-item label="计量单位" prop="measuringUnit">
  99. <DictSelection
  100. dictName="计量单位"
  101. clearable
  102. v-model="form.measuringUnit"
  103. >
  104. </DictSelection>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="重量单位" prop="weightUnit">
  109. <DictSelection
  110. dictName="重量单位"
  111. clearable
  112. v-model="form.weightUnit"
  113. >
  114. </DictSelection>
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="8">
  118. <el-form-item label="包装单位" prop="packingUnit">
  119. <DictSelection
  120. dictName="包装单位"
  121. clearable
  122. v-model="form.packingUnit"
  123. >
  124. </DictSelection>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8">
  128. <el-form-item label="体积">
  129. <div class="form-line">
  130. <el-input v-model="form.volume" />
  131. <DictSelection
  132. class="line-select"
  133. dictName="体积单位"
  134. clearable
  135. v-model="form.volumeUnit"
  136. >
  137. </DictSelection>
  138. </div>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="8">
  142. <el-form-item label="毛重">
  143. <div class="form-line">
  144. <el-input v-model="form.roughWeight" />
  145. </div>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="8">
  149. <el-form-item label="净重">
  150. <div class="form-line">
  151. <el-input v-model="form.netWeight" />
  152. </div>
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="8">
  156. <el-form-item label="级别">
  157. <template>
  158. <el-select
  159. style="width: 100%"
  160. v-model="form.level"
  161. placeholder="请选择"
  162. >
  163. <el-option
  164. v-for="item in levelOptions"
  165. :label="item.label"
  166. :value="item.value"
  167. :key="item.value"
  168. >
  169. </el-option>
  170. </el-select>
  171. </template>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
  175. <el-form-item :label="f.label">
  176. <template>
  177. <div class="form-line">
  178. <component
  179. :is="f.tagType"
  180. v-model="form.extField[f.prop]"
  181. :disabled="f.extAttribute?.disabled"
  182. clearable
  183. :isProhibit="
  184. f.modelType == 'dict' ? f.extAttribute?.disabled : false
  185. "
  186. :dictName="f.modelType == 'dict' ? f.label : ''"
  187. ></component>
  188. </div>
  189. </template>
  190. </el-form-item>
  191. </el-col>
  192. </el-row>
  193. </el-form>
  194. </el-card>
  195. <!-- 自定义编码 -->
  196. <CodeDialog
  197. ref="codeRefs"
  198. v-if="codeShow"
  199. @close="codeShow = false"
  200. @chooseCode="chooseCode"
  201. ></CodeDialog>
  202. <!-- 分类选择弹窗 -->
  203. <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
  204. <!-- 仓储配置 -->
  205. <WarehouseInfo
  206. ref="warehouseRefs"
  207. :form="categoryWms"
  208. :measuringUnit="form.measuringUnit"
  209. :packageDispositionVOList="packageDispositionVOList"
  210. @change="changePackagingSpecification"
  211. />
  212. <!-- 生产信息 -->
  213. <ProductionInfo ref="productionRefs" :form="categoryMes" />
  214. <!-- 计划 -->
  215. <PlanInfo ref="planRefs" :form="categoryAps" />
  216. <!-- 质量配置 -->
  217. <QualityInfo ref="qualityRefs" :form="categoryQms" />
  218. <!-- 舟皿信息 -->
  219. <BoatInfo ref="qualityRefs" :form="categoryPallet" />
  220. <!-- 周转车信息 -->
  221. <TurnoverInfo ref="turnoverRefs" :form="categoryVehicle" />
  222. <!-- 模具信息 -->
  223. <MoldInfo ref="moldRefs" :form="categoryMold" />
  224. <!-- 备注信息 -->
  225. <RemarkInfo ref="remarkRefs" :form="remarkform" />
  226. <!-- 关联信息 -->
  227. <linkMsg
  228. ref="linkMsgRef"
  229. :id="$route.query.id"
  230. :categoryLevelId="form.categoryLevelId"
  231. :categoryLevelGroupId="form.categoryLevelGroupId"
  232. />
  233. </div>
  234. </template>
  235. <script>
  236. import GroupDialog from './components/GroupDialog.vue';
  237. import CodeDialog from './components/codeDialog.vue';
  238. import CategoryDialog from './components/CategoryDialog.vue';
  239. import WarehouseInfo from './components/WarehouseInfo.vue';
  240. import ProcureInfo from './components/ProcureInfo.vue';
  241. import ProductionInfo from './components/ProductionInfo.vue';
  242. import PlanInfo from './components/PlanInfo.vue';
  243. import SalesInfo from './components/SalesInfo.vue';
  244. import QualityInfo from './components/QualityInfo.vue';
  245. import BoatInfo from './components/BoatInfo.vue';
  246. import TurnoverInfo from './components/TurnoverInfo.vue';
  247. import MoldInfo from './components/MoldInfo.vue';
  248. import RemarkInfo from './components/RemarkInfo.vue';
  249. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  250. import personSelect from '@/components/CommomSelect/person-select.vue';
  251. import linkMsg from './components/link-msg.vue';
  252. import { getDetails } from '@/api/classifyManage/itemInformation';
  253. import { getByCode } from '@/api/system/dictionary-data';
  254. import { getCode, rootCategoryCode, fieldModel } from '@/api/codeManagement';
  255. import { addMaterial } from '@/api/material/list.js';
  256. import { deepClone } from '@/utils/index';
  257. import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
  258. export default {
  259. name: 'ManageMaterial',
  260. components: {
  261. linkMsg,
  262. GroupDialog,
  263. deptSelect,
  264. personSelect,
  265. WarehouseInfo,
  266. ProcureInfo,
  267. ProductionInfo,
  268. PlanInfo,
  269. SalesInfo,
  270. QualityInfo,
  271. BoatInfo,
  272. TurnoverInfo,
  273. MoldInfo,
  274. RemarkInfo,
  275. CategoryDialog,
  276. CodeDialog
  277. },
  278. data() {
  279. return {
  280. packagingSpecificationList: [],
  281. loading: false,
  282. levelOptions: [
  283. {
  284. label: '特级',
  285. value: '特级'
  286. },
  287. {
  288. label: '一级',
  289. value: '一级'
  290. },
  291. {
  292. label: '二级',
  293. value: '二级'
  294. },
  295. {
  296. label: '三级',
  297. value: '三级'
  298. }
  299. ],
  300. form: {
  301. categoryLevelGroupName: '',
  302. categoryLevelName: '',
  303. isConsumable: 1,
  304. extField: {}
  305. },
  306. remarkform: {
  307. remarkAttach: []
  308. },
  309. categoryAps: {},
  310. categoryMes: {},
  311. categoryMold: {},
  312. categoryPallet: {},
  313. categoryQms: {},
  314. categoryVehicle: {},
  315. categoryWms: {
  316. isUnpack: 1
  317. },
  318. packageDispositionVOList: [],
  319. categoryLevelPathId: null,
  320. dictList: [],
  321. fileList: [],
  322. // 表单验证规则
  323. rules: {
  324. categoryLevelGroupName: [
  325. { required: true, message: '请选择所属物料组', trigger: 'change' }
  326. ],
  327. code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  328. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  329. categoryLevelName: [
  330. { required: true, message: '请选择所属分类', trigger: 'change' }
  331. ],
  332. measuringUnit: [
  333. { required: true, message: '请选择计量单位', trigger: 'change' }
  334. ],
  335. weightUnit: [
  336. { required: true, message: '请选择重量单位', trigger: 'change' }
  337. ],
  338. packingUnit: [
  339. { required: true, message: '请选择包装单位', trigger: 'change' }
  340. ],
  341. netWeight: [
  342. { required: true, message: '请输入净重', trigger: 'blur' }
  343. ]
  344. },
  345. PathInfo: {},
  346. id: null,
  347. ruleCode: null,
  348. codeShow: false,
  349. status: null
  350. };
  351. },
  352. watch: {
  353. '$route.query.id': {
  354. handler(id) {
  355. console.log('id-------------', id);
  356. if (id) {
  357. this._getDetails();
  358. } else {
  359. this.form = {
  360. categoryLevelGroupName: '',
  361. categoryLevelName: '',
  362. isConsumable: 1,
  363. extField: {}
  364. };
  365. this.remarkform = {
  366. remarkAttach: []
  367. };
  368. this.categoryAps = {};
  369. this.categoryMes = {};
  370. this.categoryMold = {};
  371. this.categoryPallet = {};
  372. this.categoryQms = {};
  373. this.categoryVehicle = {};
  374. this.categoryWms = {
  375. isUnpack: 1
  376. };
  377. this.packageDispositionVOList = [];
  378. this.categoryLevelPathId = null;
  379. this.dictList = [];
  380. this.fileList = [];
  381. }
  382. },
  383. deep: true,
  384. immediate: true
  385. }
  386. },
  387. async created() {
  388. this.getFieldModel();
  389. this.status = this.$route.query.status;
  390. // if (this.$route.query.id) {
  391. // this._getDetails();
  392. // }
  393. this.getDictList('productionType');
  394. },
  395. methods: {
  396. changePackagingSpecification(val) {
  397. this.packagingSpecificationList = val;
  398. },
  399. async _getDetails() {
  400. const data = await getDetails(this.$route.query.id);
  401. const info = deepClone(data);
  402. this.form = {
  403. ...info.category
  404. };
  405. let productType_ = this.form.produceType;
  406. if (productType_ != undefined && productType_ != null) {
  407. let intproductType = [];
  408. for (const [index, value] of productType_.entries()) {
  409. intproductType.push(value.toString());
  410. }
  411. this.form.produceType = intproductType;
  412. }
  413. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  414. this.judgeSet(info);
  415. if (this.status == 1) {
  416. rootCategoryCode(this.categoryLevelPathId).then((res) => {
  417. this.$set(this.form, 'code', res);
  418. });
  419. }
  420. this.$forceUpdate();
  421. },
  422. // 判断字段类型并赋值
  423. judgeSet(info) {
  424. console.log('info-------', info);
  425. if (typeof info.categoryAps == 'string') {
  426. this.categoryAps = {};
  427. } else {
  428. this.categoryAps = info.categoryAps;
  429. }
  430. if (typeof info.categoryMes == 'string') {
  431. this.categoryMes = {};
  432. } else {
  433. this.categoryMes = info.categoryMes;
  434. }
  435. if (typeof info.categoryMold == 'string') {
  436. this.categoryMold = {};
  437. } else {
  438. this.categoryMold = info.categoryMold;
  439. }
  440. if (typeof info.categoryPallet == 'string') {
  441. this.categoryPallet = {};
  442. } else {
  443. this.categoryPallet = info.categoryPallet;
  444. }
  445. if (typeof info.categoryQms == 'string') {
  446. this.categoryQms = {};
  447. } else {
  448. this.categoryQms = info.categoryQms;
  449. }
  450. if (typeof info.categoryVehicle == 'string') {
  451. this.categoryVehicle = {};
  452. } else {
  453. this.categoryVehicle = info.categoryVehicle;
  454. }
  455. if (typeof info.categoryWms == 'string') {
  456. this.categoryWms = {};
  457. } else {
  458. this.categoryWms = info.categoryWms;
  459. }
  460. if (typeof info.packageDispositionVOList == 'string') {
  461. this.packageDispositionVOList = [];
  462. } else {
  463. this.packageDispositionVOList = info.packageDispositionVOList;
  464. console.log(
  465. 'this.packageDispositionVOList---!!!----',
  466. this.packageDispositionVOList
  467. );
  468. }
  469. },
  470. getFieldModel() {
  471. fieldModel({ relevance: 't_main_category' }).then((res) => {
  472. this.fileList = res;
  473. this.fileList.forEach((f) => {
  474. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  475. });
  476. });
  477. },
  478. // 确定分类
  479. async confirmCategory(node, title, PathInfo, ruleCode) {
  480. if (this.status != 0) {
  481. this.$set(this.form, 'code', null);
  482. }
  483. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  484. if (title == '选择产品分类') {
  485. this.$set(this.form, 'productCategoryLevelName', node.name);
  486. this.$set(this.form, 'productCategoryLevelId', node.id);
  487. } else {
  488. this.$set(this.form, 'categoryLevelName', node.name);
  489. this.$set(this.form, 'categoryLevelId', node.id);
  490. this.$set(this.form, 'categoryLevelPath', node.name);
  491. this.$set(this.form, 'categoryLevelPathId', node.id);
  492. this.PathInfo = PathInfo;
  493. this.ruleCode = ruleCode;
  494. if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  495. const code = await getCode(ruleCode);
  496. this.$set(this.form, 'code', code);
  497. }
  498. }
  499. this.$forceUpdate();
  500. },
  501. async getDictList(code) {
  502. let { data: res } = await getByCode(code);
  503. this.dictList = res.map((item) => {
  504. let values = Object.keys(item);
  505. return {
  506. value: Number(values[0]),
  507. label: item[values[0]]
  508. };
  509. });
  510. },
  511. openCategory() {
  512. this.$refs.categoryRefs.open();
  513. },
  514. openCode() {
  515. this.codeShow = true;
  516. },
  517. chooseCode(code) {
  518. this.$set(this.form, 'code', code);
  519. this.codeShow = false;
  520. this.$forceUpdate();
  521. },
  522. cancel() {
  523. finishPageTab();
  524. this.$router.go(-1);
  525. },
  526. // 保存
  527. submit() {
  528. this.$refs.manageForm.validate(async (valid) => {
  529. let productionValid = await this.$refs.productionRefs.getFormValid();
  530. console.log(productionValid);
  531. if (!valid || !productionValid) {
  532. return false;
  533. }
  534. let packageDispositionVOList = [];
  535. if (this.packagingSpecificationList.length > 0) {
  536. packageDispositionVOList = this.packagingSpecificationList.map(
  537. (item) => {
  538. let obj = {
  539. code: item.code,
  540. name: item.name
  541. };
  542. return [
  543. {
  544. ...obj,
  545. id: item.id0,
  546. sort: 0,
  547. status: item.status,
  548. packageCell: 1,
  549. packageUnit: item.packageUnit,
  550. conversionUnit: item.packageUnit
  551. },
  552. {
  553. ...obj,
  554. id: item.id1,
  555. sort: 1,
  556. packageCell: item.minPackageCell,
  557. packageUnit: item.packageUnit,
  558. conversionUnit: item.minConversionUnit,
  559. status: item.status
  560. },
  561. {
  562. ...obj,
  563. id: item.id2,
  564. sort: 2,
  565. packageCell: item.inPackageCell,
  566. packageUnit: item.minConversionUnit,
  567. conversionUnit: item.inConversionUnit,
  568. status: item.status
  569. },
  570. {
  571. ...obj,
  572. id: item.id3,
  573. sort: 3,
  574. packageCell: item.outPackageCell,
  575. packageUnit: item.inConversionUnit,
  576. conversionUnit: item.outConversionUnit,
  577. status: item.status
  578. }
  579. ];
  580. }
  581. );
  582. let packagingSpecificationList =
  583. this.packagingSpecificationList.filter(
  584. (item) => item.status == 1
  585. );
  586. this.form.extField.packingSpecification = packagingSpecificationList
  587. .map((item) => {
  588. return [
  589. `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
  590. `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
  591. `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
  592. ];
  593. })
  594. .flat()
  595. .join(',');
  596. } else {
  597. this.form.extField.packingSpecification = '';
  598. }
  599. this.loading = true;
  600. // const imgList = this.remarkform.imgList;
  601. // const arr = [];
  602. // if (imgList.length) {
  603. // imgList.map((item) => {
  604. // arr.push(item.storePath);
  605. // });
  606. // this.form.remarkAttach = arr.join(',');
  607. // }
  608. // this.form.remark = this.remarkform.remark
  609. // ? this.remarkform.remark
  610. // : '';
  611. const data = {
  612. categoryWms: this.categoryWms,
  613. categoryAps: this.categoryAps,
  614. categoryMes: this.categoryMes,
  615. categoryMold: this.categoryMold,
  616. categoryPallet: this.categoryPallet,
  617. categoryQms: this.categoryQms,
  618. categoryVehicle: this.categoryVehicle,
  619. category: {
  620. ...this.form,
  621. ...this.remarkform,
  622. ...this.PathInfo
  623. },
  624. packageDispositionVOList: packageDispositionVOList.flat()
  625. };
  626. if (this.$route.query.status == 1) {
  627. data.category.id = null;
  628. data.categoryWms.id = null;
  629. data.categoryAps.id = null;
  630. data.categoryMes.id = null;
  631. data.categoryMold.id = null;
  632. data.categoryPallet.id = null;
  633. data.categoryQms.id = null;
  634. data.categoryVehicle.id = null;
  635. data.packageDispositionVOList = data.packageDispositionVOList.map(
  636. (item) => {
  637. return {
  638. ...item,
  639. id: null
  640. };
  641. }
  642. );
  643. }
  644. addMaterial(data)
  645. .then((msg) => {
  646. this.loading = false;
  647. this.$message.success(msg);
  648. reloadPageTab({ fullPath: '/material/product' });
  649. this.$router.go(-1);
  650. })
  651. .catch((e) => {
  652. this.loading = false;
  653. });
  654. });
  655. }
  656. }
  657. };
  658. </script>
  659. <style lang="scss" scoped>
  660. .ele-page-header {
  661. border: none;
  662. }
  663. .body-top {
  664. display: flex;
  665. align-items: center;
  666. justify-content: space-between;
  667. background: #fff;
  668. .top-left {
  669. display: flex;
  670. align-items: center;
  671. justify-content: flex-start;
  672. margin-left: -25px;
  673. .el-form-item {
  674. margin-bottom: 0;
  675. }
  676. }
  677. }
  678. .divider {
  679. margin: 20px 0;
  680. .title {
  681. display: flex;
  682. align-items: center;
  683. margin-bottom: 10px;
  684. div {
  685. width: 8px;
  686. height: 20px;
  687. margin-right: 10px;
  688. }
  689. span {
  690. font-size: 20px;
  691. }
  692. }
  693. .ele-width {
  694. width: 100%;
  695. height: 2px;
  696. }
  697. }
  698. .form-line {
  699. display: flex;
  700. align-items: center;
  701. justify-content: space-between;
  702. .line-select {
  703. margin-left: 15px;
  704. }
  705. }
  706. </style>