detail.vue 29 KB

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