detail.vue 35 KB

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