detail.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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: 'product',
  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. produceType: [
  330. { required: true, message: '请选择生产类型', trigger: 'change' }
  331. ],
  332. categoryLevelName: [
  333. { required: true, message: '请选择所属分类', trigger: 'change' }
  334. ],
  335. measuringUnit: [
  336. { required: true, message: '请选择计量单位', trigger: 'change' }
  337. ],
  338. weightUnit: [
  339. { required: true, message: '请选择重量单位', trigger: 'change' }
  340. ],
  341. packingUnit: [
  342. { required: true, message: '请选择包装单位', trigger: 'change' }
  343. ],
  344. netWeight: [
  345. { required: true, message: '请输入净重', trigger: 'blur' }
  346. ]
  347. },
  348. PathInfo: {},
  349. id: null,
  350. ruleCode: null,
  351. codeShow: false,
  352. status: null
  353. };
  354. },
  355. watch: {
  356. '$route.query.id': {
  357. handler(id) {
  358. if (id) {
  359. this._getDetails();
  360. } else {
  361. this.form = {
  362. categoryLevelGroupName: '',
  363. categoryLevelName: '',
  364. isConsumable: 1,
  365. extField: {}
  366. };
  367. this.remarkform = {
  368. remarkAttach: []
  369. };
  370. this.categoryAps = {};
  371. this.categoryMes = {};
  372. this.categoryMold = {};
  373. this.categoryPallet = {};
  374. this.categoryQms = {};
  375. this.categoryVehicle = {};
  376. this.categoryWms = {
  377. isUnpack: 1
  378. };
  379. this.packageDispositionVOList = [];
  380. this.categoryLevelPathId = null;
  381. this.dictList = [];
  382. this.fileList = [];
  383. }
  384. },
  385. deep: true,
  386. immediate: true
  387. }
  388. },
  389. async created() {
  390. this.getFieldModel();
  391. this.status = this.$route.query.status;
  392. // if (this.$route.query.id) {
  393. // this._getDetails();
  394. // }
  395. this.getDictList('productionType');
  396. },
  397. methods: {
  398. changePackagingSpecification(val) {
  399. this.packagingSpecificationList = val;
  400. },
  401. async _getDetails() {
  402. const data = await getDetails(this.$route.query.id);
  403. const info = deepClone(data);
  404. this.form = {
  405. ...info.category
  406. };
  407. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  408. this.judgeSet(info);
  409. if (this.status == 1) {
  410. rootCategoryCode(this.categoryLevelPathId).then((res) => {
  411. this.$set(this.form, 'code', res);
  412. });
  413. }
  414. this.$forceUpdate();
  415. },
  416. // 判断字段类型并赋值
  417. judgeSet(info) {
  418. console.log('info-------', info);
  419. if (typeof info.categoryAps == 'string') {
  420. this.categoryAps = {};
  421. } else {
  422. this.categoryAps = info.categoryAps;
  423. }
  424. if (typeof info.categoryMes == 'string') {
  425. this.categoryMes = {};
  426. } else {
  427. this.categoryMes = info.categoryMes;
  428. }
  429. if (typeof info.categoryMold == 'string') {
  430. this.categoryMold = {};
  431. } else {
  432. this.categoryMold = info.categoryMold;
  433. }
  434. if (typeof info.categoryPallet == 'string') {
  435. this.categoryPallet = {};
  436. } else {
  437. this.categoryPallet = info.categoryPallet;
  438. }
  439. if (typeof info.categoryQms == 'string') {
  440. this.categoryQms = {};
  441. } else {
  442. this.categoryQms = info.categoryQms;
  443. }
  444. if (typeof info.categoryVehicle == 'string') {
  445. this.categoryVehicle = {};
  446. } else {
  447. this.categoryVehicle = info.categoryVehicle;
  448. }
  449. if (typeof info.categoryWms == 'string') {
  450. this.categoryWms = {};
  451. } else {
  452. this.categoryWms = info.categoryWms;
  453. }
  454. if (typeof info.packageDispositionVOList == 'string') {
  455. this.packageDispositionVOList = [];
  456. } else {
  457. this.packageDispositionVOList = info.packageDispositionVOList;
  458. console.log(
  459. 'this.packageDispositionVOList---!!!----',
  460. this.packageDispositionVOList
  461. );
  462. }
  463. },
  464. getFieldModel() {
  465. fieldModel({ relevance: 't_main_category' }).then((res) => {
  466. this.fileList = res;
  467. this.fileList.forEach((f) => {
  468. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  469. });
  470. });
  471. },
  472. // 确定分类
  473. async confirmCategory(node, title, PathInfo, ruleCode) {
  474. if (this.status != 0) {
  475. this.$set(this.form, 'code', null);
  476. }
  477. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  478. if (title == '选择产品分类') {
  479. this.$set(this.form, 'productCategoryLevelName', node.name);
  480. this.$set(this.form, 'productCategoryLevelId', node.id);
  481. } else {
  482. this.$set(this.form, 'categoryLevelName', node.name);
  483. this.$set(this.form, 'categoryLevelId', node.id);
  484. this.$set(this.form, 'categoryLevelPath', node.name);
  485. this.$set(this.form, 'categoryLevelPathId', node.id);
  486. this.PathInfo = PathInfo;
  487. this.ruleCode = ruleCode;
  488. if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  489. const code = await getCode(ruleCode);
  490. this.$set(this.form, 'code', code);
  491. }
  492. }
  493. this.$forceUpdate();
  494. },
  495. async getDictList(code) {
  496. let { data: res } = await getByCode(code);
  497. this.dictList = res.map((item) => {
  498. let values = Object.keys(item);
  499. return {
  500. value: Number(values[0]),
  501. label: item[values[0]]
  502. };
  503. });
  504. },
  505. openCategory() {
  506. this.$refs.categoryRefs.open();
  507. },
  508. openCode() {
  509. this.codeShow = true;
  510. },
  511. chooseCode(code) {
  512. this.$set(this.form, 'code', code);
  513. this.codeShow = false;
  514. this.$forceUpdate();
  515. },
  516. cancel() {
  517. finishPageTab();
  518. this.$router.go(-1);
  519. },
  520. // 保存
  521. submit() {
  522. this.$refs.manageForm.validate(async (valid) => {
  523. let productionValid = await this.$refs.productionRefs.getFormValid();
  524. console.log(productionValid);
  525. if (!valid || !productionValid) {
  526. return false;
  527. }
  528. let packageDispositionVOList = [];
  529. if (this.packagingSpecificationList.length > 0) {
  530. packageDispositionVOList = this.packagingSpecificationList.map(
  531. (item) => {
  532. let obj = {
  533. code: item.code,
  534. name: item.name
  535. };
  536. return [
  537. {
  538. ...obj,
  539. id: item.id0,
  540. sort: 0,
  541. status: item.status,
  542. packageCell: 1,
  543. packageUnit: item.packageUnit,
  544. conversionUnit: item.packageUnit
  545. },
  546. {
  547. ...obj,
  548. id: item.id1,
  549. sort: 1,
  550. packageCell: item.minPackageCell,
  551. packageUnit: item.packageUnit,
  552. conversionUnit: item.minConversionUnit,
  553. status: item.status
  554. },
  555. {
  556. ...obj,
  557. id: item.id2,
  558. sort: 2,
  559. packageCell: item.inPackageCell,
  560. packageUnit: item.minConversionUnit,
  561. conversionUnit: item.inConversionUnit,
  562. status: item.status
  563. },
  564. {
  565. ...obj,
  566. id: item.id3,
  567. sort: 3,
  568. packageCell: item.outPackageCell,
  569. packageUnit: item.inConversionUnit,
  570. conversionUnit: item.outConversionUnit,
  571. status: item.status
  572. }
  573. ];
  574. }
  575. );
  576. let packagingSpecificationList =
  577. this.packagingSpecificationList.filter(
  578. (item) => item.status == 1
  579. );
  580. this.form.extField.packingSpecification = packagingSpecificationList
  581. .map((item) => {
  582. return [
  583. `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
  584. `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
  585. `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
  586. ];
  587. })
  588. .flat()
  589. .join(',');
  590. } else {
  591. this.form.extField.packingSpecification = '';
  592. }
  593. this.loading = true;
  594. // const imgList = this.remarkform.imgList;
  595. // const arr = [];
  596. // if (imgList.length) {
  597. // imgList.map((item) => {
  598. // arr.push(item.storePath);
  599. // });
  600. // this.form.remarkAttach = arr.join(',');
  601. // }
  602. // this.form.remark = this.remarkform.remark
  603. // ? this.remarkform.remark
  604. // : '';
  605. const data = {
  606. categoryWms: this.categoryWms,
  607. categoryAps: this.categoryAps,
  608. categoryMes: this.categoryMes,
  609. categoryMold: this.categoryMold,
  610. categoryPallet: this.categoryPallet,
  611. categoryQms: this.categoryQms,
  612. categoryVehicle: this.categoryVehicle,
  613. category: {
  614. ...this.form,
  615. ...this.remarkform,
  616. ...this.PathInfo
  617. },
  618. packageDispositionVOList: packageDispositionVOList.flat()
  619. };
  620. if (this.$route.query.status == 1) {
  621. data.category.id = null;
  622. data.categoryWms.id = null;
  623. data.categoryAps.id = null;
  624. data.categoryMes.id = null;
  625. data.categoryMold.id = null;
  626. data.categoryPallet.id = null;
  627. data.categoryQms.id = null;
  628. data.categoryVehicle.id = null;
  629. data.packageDispositionVOList = data.packageDispositionVOList.map(
  630. (item) => {
  631. return {
  632. ...item,
  633. id: null
  634. };
  635. }
  636. );
  637. }
  638. addMaterial(data)
  639. .then((msg) => {
  640. this.loading = false;
  641. this.$message.success(msg);
  642. reloadPageTab({ fullPath: '/material/product' });
  643. this.$router.go(-1);
  644. })
  645. .catch((e) => {
  646. this.loading = false;
  647. });
  648. });
  649. }
  650. }
  651. };
  652. </script>
  653. <style lang="scss" scoped>
  654. .ele-page-header {
  655. border: none;
  656. }
  657. .body-top {
  658. display: flex;
  659. align-items: center;
  660. justify-content: space-between;
  661. background: #fff;
  662. .top-left {
  663. display: flex;
  664. align-items: center;
  665. justify-content: flex-start;
  666. margin-left: -25px;
  667. .el-form-item {
  668. margin-bottom: 0;
  669. }
  670. }
  671. }
  672. .divider {
  673. margin: 20px 0;
  674. .title {
  675. display: flex;
  676. align-items: center;
  677. margin-bottom: 10px;
  678. div {
  679. width: 8px;
  680. height: 20px;
  681. margin-right: 10px;
  682. }
  683. span {
  684. font-size: 20px;
  685. }
  686. }
  687. .ele-width {
  688. width: 100%;
  689. height: 2px;
  690. }
  691. }
  692. .form-line {
  693. display: flex;
  694. align-items: center;
  695. justify-content: space-between;
  696. .line-select {
  697. margin-left: 15px;
  698. }
  699. }
  700. </style>