detail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <el-form label-width="100px" ref="manageForm" :model="form" :rules="rules">
  5. <headerTitle title="基本信息">
  6. <el-button @click="cancel">返回</el-button>
  7. <el-button type="primary" @click="submit" :loading="loading">保存
  8. </el-button>
  9. </headerTitle>
  10. <el-row :gutter="24">
  11. <el-col :span="8">
  12. <el-form-item label="分类" prop="categoryLevelName">
  13. <el-input v-model="form.categoryLevelName" @click.native="openCategory" />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-form-item label="编码" prop="code">
  18. <el-input v-if="ruleCode == '自定义'" v-model="form.code" readonly @click.native="openCode"
  19. :disabled="status == 0" />
  20. <el-input v-else v-model="form.code" :disabled="status == 0" />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="名称" prop="name">
  25. <el-input v-model="form.name" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8">
  29. <el-form-item label="物料类型:" prop="attributeType">
  30. <el-select v-model="form.attributeType" filterable class="ele-block">
  31. <el-option v-for="item in attributeList" :key="item.value" :value="item.value"
  32. :label="item.label"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="8">
  37. <div>
  38. <el-form-item label="属性类型" prop="produceType">
  39. <el-select style="width: 100%" v-model="form.componentAttribute" filterable multiple>
  40. <el-option v-for="item in lbjtList" :key="item.value" :value="item.value"
  41. :label="item.label"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. </div>
  45. </el-col>
  46. <el-col :span="8">
  47. <div>
  48. <el-form-item label="生产类型" prop="produceType">
  49. <el-select style="width: 100%" v-model="form.produceType" filterable multiple>
  50. <el-option v-for="item in dictList" :key="item.value" :value="item.value"
  51. :label="item.label"></el-option>
  52. </el-select>
  53. </el-form-item>
  54. </div>
  55. </el-col>
  56. <el-col :span="8">
  57. <!-- v-if="
  58. [1, 23, 9, 28].includes(
  59. Number(categoryLevelPathId || $route.query.rootTreeId)
  60. )
  61. " -->
  62. <el-form-item label="加工类型" prop="isConsumable">
  63. <el-select v-model="form.isConsumable" style="width: 100%" @change="changeConsumable">
  64. <el-option :value="1" label="批量"></el-option>
  65. <el-option :value="0" label="单件"></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="8">
  70. <el-form-item label="牌号" prop="brandNum">
  71. <el-input v-model="form.brandNum" />
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-form-item label="型号" prop="modelType">
  76. <el-input v-model="form.modelType" />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="规格" prop="specification">
  81. <el-input v-model="form.specification" @input="inputSpe" />
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="8">
  85. <el-form-item label="计量类型" prop="measureType">
  86. <el-select v-model="form.measureType" style="width: 100%" @change="changeMeasureType">
  87. <el-option v-for="item in measureTypeList" :key="item.value" :value="item.value"
  88. :label="item.label"></el-option>
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8">
  93. <el-form-item label="计量单位" prop="measuringUnit">
  94. <DictSelection dictName="计量单位" clearable v-model="form.measuringUnit" @change="changeUnit">
  95. </DictSelection>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="8">
  99. <el-form-item label="重量单位" prop="weightUnit">
  100. <DictSelection dictName="重量单位" clearable v-model="form.weightUnit" @change="changeWeightUnit">
  101. </DictSelection>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="8">
  105. <el-form-item label="包装单位" prop="packingUnit">
  106. <DictSelection dictName="包装单位" clearable v-model="form.packingUnit" @change="changeUnit">
  107. </DictSelection>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-form-item label="图号/件号" prop="imgCode">
  112. <el-input v-model="form.imgCode" />
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="8">
  116. <el-form-item label="毛重">
  117. <div class="form-line">
  118. <el-input v-model="form.roughWeight" @input="handleInput2" />
  119. </div>
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="8">
  123. <el-form-item label="净重" prop="netWeight"
  124. :rules="{ required: form.measuringUnit == form.weightUnit, trigger: ['blur', 'change'], message: '请输入净重', }">
  125. <div class="form-line">
  126. <el-input v-model="form.netWeight" @input="handleInput3" />
  127. </div>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="8">
  131. <el-form-item label="体积">
  132. <div class="form-line">
  133. <el-input v-model="form.volume" style="width: calc(100% - 100px)" />
  134. <!-- @input="handleInput1" -->
  135. <DictSelection dictName="体积单位" clearable v-model="form.volumeUnit" style="width: 100px">
  136. </DictSelection>
  137. </div>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="8">
  141. <el-form-item label="级别">
  142. <template>
  143. <el-select style="width: 100%" v-model="form.level" placeholder="请选择">
  144. <el-option v-for="item in levelOptions" :label="item.label" :value="item.value" :key="item.value">
  145. </el-option>
  146. </el-select>
  147. </template>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="8">
  151. <el-form-item label="状态">
  152. <template>
  153. <el-switch v-model="form.isEnabled" :active-text="form.isEnabled == 1 ? '启用' : '停用'" :active-value="1"
  154. :inactive-value="0">
  155. </el-switch>
  156. </template>
  157. </el-form-item>
  158. </el-col>
  159. <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
  160. <el-form-item :label="f.label">
  161. <template>
  162. <div class="form-line">
  163. <component :is="f.tagType" v-model="form.extField[f.prop]" :disabled="f.extAttribute?.disabled"
  164. clearable :isProhibit="f.modelType == 'dict' ? f.extAttribute?.disabled : false
  165. " :dictName="f.modelType == 'dict' ? f.label : ''"></component>
  166. </div>
  167. </template>
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. </el-form>
  172. </el-card>
  173. <!-- 自定义编码 -->
  174. <CodeDialog ref="codeRefs" v-if="codeShow" @close="codeShow = false" @chooseCode="chooseCode" />
  175. <!-- 分类选择弹窗 -->
  176. <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
  177. <!-- 仓储配置 -->
  178. <WarehouseInfo ref="warehouseRefs" v-if="isShow" :form="categoryWms" :measuringUnit="form.measuringUnit"
  179. :packingUnit="form.packingUnit" :packageDispositionVOList="packageDispositionVOList"
  180. @change="changePackagingSpecification" />
  181. <!-- 销售配置 -->
  182. <SalesInfos ref="salesRefs" :form="categorySales" />
  183. <!-- 采购信息 -->
  184. <PurchasingInfo ref="PurchasingInfoRefs" :form="categoryPurchase" />
  185. <!-- 生产信息 -->
  186. <ProductionInfo ref="productionRefs" :form="categoryMes" />
  187. <!-- 计划 -->
  188. <PlanInfo ref="planRefs" :form="categoryAps" />
  189. <!-- 质量配置 -->
  190. <QualityInfo ref="qualityRefs" :form="categoryQms" />
  191. <!-- 舟皿信息 -->
  192. <BoatInfo ref="qualityRefs" :form="categoryPallet" />
  193. <!-- 周转车信息 -->
  194. <TurnoverInfo ref="turnoverRefs" :form="categoryVehicle" />
  195. <!-- 模具信息 -->
  196. <MoldInfo ref="moldRefs" :form="categoryMold" />
  197. <!-- 备注信息 -->
  198. <RemarkInfo ref="remarkRefs" :form="remarkform" />
  199. <!-- 关联信息 -->
  200. <linkMsg ref="linkMsgRef" :id="$route.query.id" :categoryLevelId="form.categoryLevelId"
  201. :categoryLevelGroupId="form.categoryLevelGroupId" :code="form.code" />
  202. </div>
  203. </template>
  204. <script>
  205. import SalesInfos from './components/SalesInfos.vue';
  206. import PurchasingInfo from './components/PurchasingInfo.vue';
  207. import GroupDialog from './components/GroupDialog.vue';
  208. import CodeDialog from './components/codeDialog.vue';
  209. import CategoryDialog from './components/CategoryDialog.vue';
  210. import WarehouseInfo from './components/WarehouseInfo.vue';
  211. import ProcureInfo from './components/ProcureInfo.vue';
  212. import ProductionInfo from './components/ProductionInfo.vue';
  213. import PlanInfo from './components/PlanInfo.vue';
  214. import SalesInfo from './components/SalesInfo.vue';
  215. import QualityInfo from './components/QualityInfo.vue';
  216. import BoatInfo from './components/BoatInfo.vue';
  217. import TurnoverInfo from './components/TurnoverInfo.vue';
  218. import MoldInfo from './components/MoldInfo.vue';
  219. import RemarkInfo from './components/RemarkInfo.vue';
  220. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  221. import personSelect from '@/components/CommomSelect/person-select.vue';
  222. import linkMsg from './components/link-msg.vue';
  223. import { getDetails } from '@/api/classifyManage/itemInformation';
  224. import { getByCode } from '@/api/system/dictionary-data';
  225. import { getCode, rootCategoryCode, fieldModel } from '@/api/codeManagement';
  226. import { addMaterial } from '@/api/material/list.js';
  227. import { deepClone } from '@/utils/index';
  228. import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
  229. export default {
  230. name: 'product',
  231. components: {
  232. SalesInfos,
  233. PurchasingInfo,
  234. linkMsg,
  235. GroupDialog,
  236. deptSelect,
  237. personSelect,
  238. WarehouseInfo,
  239. ProcureInfo,
  240. ProductionInfo,
  241. PlanInfo,
  242. SalesInfo,
  243. QualityInfo,
  244. BoatInfo,
  245. TurnoverInfo,
  246. MoldInfo,
  247. RemarkInfo,
  248. CategoryDialog,
  249. CodeDialog
  250. },
  251. data() {
  252. return {
  253. isShow: true,
  254. packagingSpecificationList: [],
  255. loading: false,
  256. measureTypeList: [
  257. {
  258. label: '数量',
  259. value: 1
  260. },
  261. {
  262. label: '重量',
  263. value: 2
  264. },
  265. {
  266. label: '体积',
  267. value: 3
  268. }, {
  269. label: '容积',
  270. value: 4
  271. },
  272. {
  273. label: '面积',
  274. value: 5
  275. },
  276. ],
  277. levelOptions: [
  278. {
  279. label: '特级',
  280. value: '特级'
  281. },
  282. {
  283. label: '一级',
  284. value: '一级'
  285. },
  286. {
  287. label: '二级',
  288. value: '二级'
  289. },
  290. {
  291. label: '三级',
  292. value: '三级'
  293. }
  294. ],
  295. form: {
  296. categoryLevelGroupName: '',
  297. componentAttribute: [],
  298. categoryLevelName: '',
  299. isConsumable: 0,
  300. measuringUnit: '',
  301. netWeight: '',
  302. attributeType: 1,
  303. weightUnit: '',
  304. packingUnit: '',
  305. isEnabled: 1,
  306. extField: {}
  307. },
  308. lbjtList: [
  309. {
  310. label: '自制件',
  311. value: 1
  312. },
  313. {
  314. label: '采购件',
  315. value: 2
  316. },
  317. {
  318. label: '外协件',
  319. value: 3
  320. }, {
  321. label: '受托件',
  322. value: 4
  323. }
  324. ],
  325. attributeList: [
  326. {
  327. label: '总装',
  328. value: 1
  329. },
  330. {
  331. label: '部件',
  332. value: 2
  333. },
  334. {
  335. label: '零件',
  336. value: 3
  337. }, {
  338. label: '原材料',
  339. value: 4
  340. }
  341. ],
  342. remarkform: {
  343. remarkAttach: []
  344. },
  345. categorySales: {},
  346. categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
  347. categoryAps: {},
  348. categoryMes: { productionDays: '1' },
  349. categoryMold: {},
  350. categoryPallet: {},
  351. categoryQms: {
  352. isComeCheck: '1'
  353. },
  354. categoryVehicle: {},
  355. categoryWms: {
  356. isUnpack: 1,
  357. isWarn: 1,
  358. inventoryMode: '',
  359. secureInventory: '1',
  360. minInventory: '1',
  361. maxInventory: '1',
  362. },
  363. packageDispositionVOList: [],
  364. categoryLevelPathId: null,
  365. dictList: [
  366. {
  367. label: '加工',
  368. value: 1
  369. },
  370. {
  371. label: '装配',
  372. value: 3
  373. },
  374. ],
  375. fileList: [],
  376. // 表单验证规则
  377. rules: {
  378. measureType: [
  379. { required: true, message: '请选择计量类型', trigger: 'change' }
  380. ],
  381. categoryLevelGroupName: [
  382. { required: true, message: '请选择所属物料组', trigger: 'change' }
  383. ],
  384. code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  385. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  386. produceType: [
  387. { required: true, message: '请选择生产类型', trigger: 'change' }
  388. ],
  389. attributeType: [
  390. { required: true, message: '请选择属性类型', trigger: 'change' }
  391. ],
  392. categoryLevelName: [
  393. { required: true, message: '请选择所属分类', trigger: 'change' }
  394. ],
  395. measuringUnit: [
  396. { required: true, message: '请选择计量单位', trigger: 'change' }
  397. ],
  398. weightUnit: [
  399. { required: true, message: '请选择重量单位', trigger: 'change' }
  400. ],
  401. packingUnit: [
  402. { required: true, message: '请选择包装单位', trigger: 'change' }
  403. ],
  404. netWeight: [
  405. { required: true, message: '请输入净重', trigger: 'blur' }
  406. ]
  407. },
  408. PathInfo: {},
  409. id: null,
  410. ruleCode: null,
  411. codeShow: false,
  412. status: null
  413. };
  414. },
  415. watch: {
  416. '$route.query.id': {
  417. handler(id) {
  418. if (id) {
  419. this._getDetails();
  420. } else {
  421. let { lyType } = this.$route.query;
  422. let arrId = '';
  423. if (lyType == "wp") {
  424. arrId = 3
  425. }
  426. if (lyType == "cp") {
  427. arrId = 1
  428. }
  429. this.form = {
  430. categoryLevelGroupName: '',
  431. // categoryLevelName: '',
  432. componentAttribute: [],
  433. isConsumable: 0,
  434. attributeType: arrId,
  435. measuringUnit: '',
  436. netWeight: '',
  437. weightUnit: '',
  438. packingUnit: '',
  439. extField: {},
  440. measureType: 1,
  441. isEnabled: 1,
  442. };
  443. this.categorySales = {};
  444. this.purchaseInfo = {};
  445. this.remarkform = {
  446. remarkAttach: []
  447. };
  448. this.categoryAps = {};
  449. this.categoryMes = { productionDays: '20', isCompleteSet: 0, isModify: 0, isRework: 0, isRematerial: 0, isByProduct: 0, isWaste: 0, isDefective: 0 };
  450. this.categoryMold = {};
  451. this.categoryPallet = {};
  452. this.categoryQms = {};
  453. this.categoryVehicle = {};
  454. this.categoryWms = {
  455. isUnpack: 1,
  456. isWarn: 1,
  457. inventoryMode: this.form.isConsumable,
  458. minPackageCell: '',
  459. secureInventory: '10',
  460. minInventory: '10',
  461. maxInventory: '10',
  462. };
  463. this.packageDispositionVOList = [];
  464. this.categoryLevelPathId = null;
  465. // this.dictList = [];
  466. this.fileList = [];
  467. }
  468. },
  469. deep: true,
  470. immediate: true
  471. }
  472. },
  473. async activated() {
  474. this.status = this.$route.query.status;
  475. this.form.categoryLevelId = this.$route.query.categoryLevelId;
  476. this.form.categoryLevelName = this.$route.query.categoryLevelName;
  477. this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
  478. this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
  479. this.ruleCode = this.$route.query.ruleCode;
  480. if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  481. const code = await getCode(this.ruleCode);
  482. this.$set(this.form, 'code', code);
  483. }
  484. this.getFieldModel();
  485. // this.getDictList('zeroPartPros');
  486. },
  487. async created() {
  488. //新增
  489. this.$set(
  490. this.form,
  491. 'categoryLevelId',
  492. this.$route.query.categoryLevelId
  493. );
  494. this.$set(
  495. this.form,
  496. 'categoryLevelName',
  497. this.$route.query.categoryLevelName
  498. );
  499. this.$set(
  500. this.form,
  501. 'categoryLevelPath',
  502. this.$route.query.categoryLevelPath
  503. );
  504. this.$set(
  505. this.form,
  506. 'categoryLevelPathId',
  507. this.$route.query.categoryLevelPathId
  508. );
  509. this.status = this.$route.query.status;
  510. this.ruleCode = this.$route.query.ruleCode;
  511. if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
  512. const code = await getCode(this.ruleCode);
  513. this.$set(this.form, 'code', code);
  514. }
  515. this.getFieldModel();
  516. this.getDictList('zeroPartPros');
  517. },
  518. methods: {
  519. inputSpe(val) {
  520. if (this.form.measuringUnit == '立方') {
  521. if (!val || typeof val !== 'string') {
  522. this.form.volume = 0;
  523. return;
  524. };
  525. let modelArr = val.split('*');
  526. let modelLong = modelArr[0]; // model规格长度
  527. let modeWide = modelArr[1]; // model规格宽度
  528. let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('cm')); // model规格高度
  529. modeHight = Number(modeHight);
  530. let aa = (modelLong * modeWide * modeHight) / 1000000;
  531. console.log(aa, 'aa')
  532. this.form.volume = aa;
  533. } else {
  534. this.form.volume = '';
  535. }
  536. },
  537. changeMeasureType() {
  538. if (this.form.measureType == 1) {
  539. this.$set(this.categoryWms, 'isUnpack', 1);
  540. } else {
  541. this.$set(this.categoryWms, 'isUnpack', 0);
  542. }
  543. },
  544. handleInput(value) {
  545. // this.form.volume = this.$handleInputPublicHasPoint(value);
  546. },
  547. handleInput2(value) {
  548. this.form.roughWeight = this.$handleInputPublicHasPoint(value);
  549. },
  550. handleInput3(value) {
  551. // this.form.netWeight = this.$handleInputPublicHasPoint(value);
  552. if (this.form.weightUnit == this.form.measuringUnit) {
  553. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  554. }
  555. },
  556. changeConsumable() {
  557. this.$set(this.categoryWms, 'inventoryMode', this.form.isConsumable);
  558. },
  559. changeWeightUnit() {
  560. if (this.form.measuringUnit && this.form.packingUnit && this.form.netWeight) {
  561. this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
  562. }
  563. },
  564. changeUnit() {
  565. if (this.$route.query.id == '' || this.$route.query.id == null) {
  566. if (this.form.measuringUnit) {
  567. // 计量单位是‘立方’ 体积单位默认是‘立方’
  568. if (this.form.measuringUnit == '立方' && this.form.specification != '') {
  569. this.form.volumeUnit = '立方';
  570. this.inputSpe(this.form.specification)
  571. } else {
  572. this.form.volume = 0;
  573. }
  574. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  575. console.log(this.categoryPurchase.measuringUnit, '采购信息');
  576. // 如果有计量单位和包装单位 默认添加包装组
  577. if (this.form.packingUnit) {
  578. this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  579. }
  580. }
  581. } else {
  582. this.isShow = false;
  583. if (this.form.measuringUnit) {
  584. this.categoryPurchase.measuringUnit = this.form.measuringUnit;
  585. if (this.form.packingUnit) {
  586. console.log(this.form.measuringUnit, 'this.form.measuringUnit');
  587. console.log(this.form.packingUnit, 'this.form.packingUnit');
  588. if (this.packageDispositionVOList.length === 0) {
  589. console.log('如果没有包装组');
  590. this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  591. }
  592. }
  593. }
  594. this.isShow = true;
  595. }
  596. },
  597. changePackagingSpecification(val) {
  598. console.log('changePackagingSpecification--------默认包装组', val);
  599. this.packagingSpecificationList = val;
  600. },
  601. async _getDetails() {
  602. const data = await getDetails(this.$route.query.id);
  603. const info = deepClone(data);
  604. this.form = {
  605. ...info.category
  606. };
  607. // if (this.form.measuringUnit && this.form.packingUnit) {
  608. // this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
  609. // }
  610. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  611. this.judgeSet(info);
  612. if (this.status == 1) {
  613. rootCategoryCode(this.categoryLevelPathId).then((res) => {
  614. this.$set(this.form, 'code', res);
  615. });
  616. this.form.createTime = null;
  617. }
  618. this.$forceUpdate();
  619. },
  620. // 判断字段类型并赋值
  621. judgeSet(info) {
  622. console.log('info-------', info);
  623. if (typeof info.categoryAps == 'string') {
  624. this.categoryAps = {};
  625. } else {
  626. this.categoryAps = info.categoryAps;
  627. }
  628. if (typeof info.categoryMes == 'string') {
  629. this.categoryMes = {};
  630. } else {
  631. this.categoryMes = info.categoryMes;
  632. }
  633. if (typeof info.categoryMold == 'string') {
  634. this.categoryMold = {};
  635. } else {
  636. this.categoryMold = info.categoryMold;
  637. }
  638. if (typeof info.categoryPallet == 'string') {
  639. this.categoryPallet = {};
  640. } else {
  641. this.categoryPallet = info.categoryPallet;
  642. }
  643. if (typeof info.categorySales == 'string') {
  644. this.categorySales = {};
  645. } else {
  646. this.categorySales = info.categorySales;
  647. }
  648. if (typeof info.categoryPurchase == 'string') {
  649. this.categoryPurchase = {};
  650. } else {
  651. this.categoryPurchase = info.categoryPurchase;
  652. }
  653. if (typeof info.categoryQms == 'string') {
  654. this.categoryQms = {};
  655. } else {
  656. this.categoryQms = info.categoryQms;
  657. }
  658. if (typeof info.categoryVehicle == 'string') {
  659. this.categoryVehicle = {};
  660. } else {
  661. this.categoryVehicle = info.categoryVehicle;
  662. }
  663. if (typeof info.categoryWms == 'string') {
  664. this.categoryWms = {};
  665. } else {
  666. this.categoryWms = info.categoryWms;
  667. }
  668. if (typeof info.packageDispositionVOList == 'string') {
  669. this.packageDispositionVOList = [];
  670. } else {
  671. this.packageDispositionVOList = info.packageDispositionVOList;
  672. console.log(
  673. 'this.packageDispositionVOList---!!!----',
  674. this.packageDispositionVOList
  675. );
  676. }
  677. },
  678. getFieldModel() {
  679. fieldModel({ relevance: 't_main_category' }).then((res) => {
  680. this.fileList = res;
  681. this.fileList.forEach((f) => {
  682. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  683. });
  684. });
  685. },
  686. // 确定分类
  687. async confirmCategory(node, title, PathInfo, ruleCode) {
  688. if (this.status != 0) {
  689. this.$set(this.form, 'code', null);
  690. }
  691. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  692. if (title == '选择产品分类') {
  693. this.$set(this.form, 'productCategoryLevelName', node.name);
  694. this.$set(this.form, 'productCategoryLevelId', node.id);
  695. } else {
  696. this.$set(this.form, 'categoryLevelName', node.name);
  697. this.$set(this.form, 'categoryLevelId', node.id);
  698. this.$set(this.form, 'categoryLevelPath', node.name);
  699. this.$set(this.form, 'categoryLevelPathId', node.id);
  700. this.PathInfo = PathInfo;
  701. this.ruleCode = ruleCode;
  702. if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  703. const code = await getCode(ruleCode);
  704. this.$set(this.form, 'code', code);
  705. }
  706. }
  707. this.$forceUpdate();
  708. },
  709. async getDictList(code) {
  710. let { data: res } = await getByCode(code);
  711. console.log('res----', res);
  712. // this.lbjtList = res.map((item) => {
  713. // let values = Object.keys(item);
  714. // return {
  715. // value: Number(values[0]),
  716. // label: item[values[0]]
  717. // };
  718. // });
  719. },
  720. openCategory() {
  721. this.$refs.categoryRefs.open();
  722. },
  723. openCode() {
  724. this.codeShow = true;
  725. },
  726. chooseCode(code) {
  727. this.$set(this.form, 'code', code);
  728. this.codeShow = false;
  729. this.$forceUpdate();
  730. },
  731. cancel() {
  732. // finishPageTab();
  733. // this.$router.go(-1);
  734. if (this.$route.query.rootTreeId == 9) {
  735. this.$router.push({
  736. path: '/product/oneProduct',
  737. query: {
  738. categoryLevelId: this.form.categoryLevelId
  739. }
  740. });
  741. } else {
  742. this.$router.push({
  743. path: '/material/product',
  744. query: {
  745. categoryLevelId: this.form.categoryLevelId
  746. }
  747. });
  748. }
  749. },
  750. // 保存
  751. submit() {
  752. this.$refs.manageForm.validate(async (valid) => {
  753. let productionValid = await this.$refs.productionRefs.getFormValid();
  754. let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
  755. if (!valid || !productionValid || !warehouseValid) {
  756. return false;
  757. }
  758. let packageDispositionVOList = [];
  759. if (this.packagingSpecificationList.length > 0) {
  760. packageDispositionVOList = this.packagingSpecificationList.map(
  761. (item) => {
  762. let obj = {
  763. code: item.code,
  764. name: item.name
  765. };
  766. return [
  767. {
  768. ...obj,
  769. id: item.id0,
  770. sort: 0,
  771. status: item.status,
  772. packageCell: 1,
  773. packageUnit: item.packageUnit,
  774. conversionUnit: item.packageUnit
  775. },
  776. {
  777. ...obj,
  778. id: item.id1,
  779. sort: 1,
  780. packageCell: item.minPackageCell,
  781. packageUnit: item.packageUnit,
  782. conversionUnit: item.minConversionUnit,
  783. status: item.status
  784. },
  785. {
  786. ...obj,
  787. id: item.id2,
  788. sort: 2,
  789. packageCell: item.inPackageCell,
  790. packageUnit: item.minConversionUnit,
  791. conversionUnit: item.inConversionUnit,
  792. status: item.status
  793. },
  794. {
  795. ...obj,
  796. id: item.id3,
  797. sort: 3,
  798. packageCell: item.outPackageCell,
  799. packageUnit: item.inConversionUnit,
  800. conversionUnit: item.outConversionUnit,
  801. status: item.status
  802. }
  803. ];
  804. }
  805. );
  806. let packagingSpecificationList =
  807. this.packagingSpecificationList.filter(
  808. (item) => item.status == 1
  809. );
  810. this.form.extField.packingSpecification = packagingSpecificationList
  811. .map((item) => {
  812. return [
  813. `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
  814. `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
  815. `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
  816. ];
  817. })
  818. .flat()
  819. .join(',');
  820. } else {
  821. this.form.extField.packingSpecification = '';
  822. }
  823. this.loading = true;
  824. // const imgList = this.remarkform.imgList;
  825. // const arr = [];
  826. // if (imgList.length) {
  827. // imgList.map((item) => {
  828. // arr.push(item.storePath);
  829. // });
  830. // this.form.remarkAttach = arr.join(',');
  831. // }
  832. // this.form.remark = this.remarkform.remark
  833. // ? this.remarkform.remark
  834. // : '';
  835. const data = {
  836. categorySales: this.categorySales,
  837. categoryPurchase: this.categoryPurchase,
  838. categoryWms: this.categoryWms,
  839. categoryAps: this.categoryAps,
  840. categoryMes: this.categoryMes,
  841. categoryMold: this.categoryMold,
  842. categoryPallet: this.categoryPallet,
  843. categoryQms: this.categoryQms,
  844. categoryVehicle: this.categoryVehicle,
  845. category: {
  846. ...this.form,
  847. ...this.remarkform,
  848. ...this.PathInfo
  849. },
  850. packageDispositionVOList: packageDispositionVOList.flat()
  851. };
  852. if (this.$route.query.status == 1) {
  853. data.categorySales.id = null;
  854. data.categoryPurchase.id = null;
  855. data.category.id = null;
  856. data.categoryWms.id = null;
  857. data.categoryAps.id = null;
  858. data.categoryMes.id = null;
  859. data.categoryMold.id = null;
  860. data.categoryPallet.id = null;
  861. data.categoryQms.id = null;
  862. data.categoryVehicle.id = null;
  863. data.packageDispositionVOList = data.packageDispositionVOList.map(
  864. (item) => {
  865. return {
  866. ...item,
  867. id: null
  868. };
  869. }
  870. );
  871. }
  872. console.log('保存', data);
  873. addMaterial(data)
  874. .then((msg) => {
  875. this.loading = false;
  876. this.$message.success(msg);
  877. // reloadPageTab({ fullPath: '/material/product' });
  878. // this.$router.go(-1);
  879. this.cancel();
  880. // if (this.$route.query.rootTreeId == 9) {
  881. // this.$router.push({
  882. // path: '/product/oneProduct',
  883. // query: {
  884. // categoryLevelId: this.form.categoryLevelId
  885. // }
  886. // });
  887. // } else {
  888. // this.$router.push({
  889. // path: '/material/product',
  890. // query: {
  891. // categoryLevelId: this.form.categoryLevelId
  892. // }
  893. // });
  894. // }
  895. })
  896. .catch((e) => {
  897. this.loading = false;
  898. });
  899. });
  900. }
  901. }
  902. };
  903. </script>
  904. <style lang="scss" scoped>
  905. .ele-page-header {
  906. border: none;
  907. }
  908. .body-top {
  909. display: flex;
  910. align-items: center;
  911. justify-content: space-between;
  912. background: #fff;
  913. .top-left {
  914. display: flex;
  915. align-items: center;
  916. justify-content: flex-start;
  917. margin-left: -25px;
  918. .el-form-item {
  919. margin-bottom: 0;
  920. }
  921. }
  922. }
  923. .divider {
  924. margin: 20px 0;
  925. .title {
  926. display: flex;
  927. align-items: center;
  928. margin-bottom: 10px;
  929. div {
  930. width: 8px;
  931. height: 20px;
  932. margin-right: 10px;
  933. }
  934. span {
  935. font-size: 20px;
  936. }
  937. }
  938. .ele-width {
  939. width: 100%;
  940. height: 2px;
  941. }
  942. }
  943. .form-line {
  944. display: flex;
  945. align-items: center;
  946. justify-content: space-between;
  947. .line-select {
  948. margin-left: 15px;
  949. }
  950. }
  951. </style>