detail.vue 32 KB

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