detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <el-form
  5. label-width="120px"
  6. ref="manageForm"
  7. :model="form"
  8. :rules="rules"
  9. >
  10. <headerTitle title="基本信息">
  11. <el-button @click="cancel">返回</el-button>
  12. <el-button type="primary" @click="submit" :loading="loading"
  13. >保存</el-button
  14. >
  15. </headerTitle>
  16. <el-row :gutter="24">
  17. <el-col :span="8">
  18. <el-form-item label="分类" prop="categoryLevelName">
  19. <el-input
  20. v-model="form.categoryLevelName"
  21. @click.native="openCategory"
  22. />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="8" v-if="ruleCode == '自定义'" key="1">
  26. <el-form-item label="编码" prop="code">
  27. <el-input
  28. v-model="form.code"
  29. readonly
  30. @click.native="openCode"
  31. :disabled="status == 0"
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8" v-else key="2">
  36. <el-form-item label="编码" prop="code">
  37. <el-input v-model="form.code" :disabled="status == 0" />
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="8">
  41. <el-form-item label="名称" prop="name">
  42. <el-input v-model="form.name" />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="8">
  46. <el-form-item label="图号/件号" prop="imgCode">
  47. <el-input v-model="form.imgCode" />
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="8">
  51. <el-form-item label="生产类型" prop="produceType">
  52. <el-select
  53. style="width: 100%"
  54. v-model="form.produceType"
  55. filterable
  56. multiple
  57. >
  58. <el-option
  59. v-for="item in dictList"
  60. :key="item.value"
  61. :value="item.value"
  62. :label="item.label"
  63. ></el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col
  68. :span="8"
  69. v-if="[1, 23, 9, 28].includes(Number(categoryLevelPathId))"
  70. >
  71. <el-form-item label="加工类型" prop="isConsumable">
  72. <el-select
  73. v-model="form.isConsumable"
  74. size="small"
  75. style="width: 100%"
  76. >
  77. <el-option :value="1" label="批量"></el-option>
  78. <el-option :value="0" label="单件"></el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8">
  83. <el-form-item label="牌号" prop="brandNum">
  84. <el-input v-model="form.brandNum" />
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="型号" prop="modelType">
  89. <el-input v-model="form.modelType" />
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8">
  93. <el-form-item label="规格" prop="specification">
  94. <el-input v-model="form.specification" />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-form-item label="计量单位" prop="measuringUnit">
  99. <DictSelection
  100. dictName="计量单位"
  101. clearable
  102. v-model="form.measuringUnit"
  103. >
  104. </DictSelection>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="重量单位" prop="weightUnit">
  109. <DictSelection
  110. dictName="重量单位"
  111. clearable
  112. v-model="form.weightUnit"
  113. >
  114. </DictSelection>
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="8">
  118. <el-form-item label="包装单位" prop="packingUnit">
  119. <DictSelection
  120. dictName="包装单位"
  121. clearable
  122. v-model="form.packingUnit"
  123. >
  124. </DictSelection>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8">
  128. <el-form-item label="体积">
  129. <div class="form-line">
  130. <el-input v-model="form.volume" />
  131. <DictSelection
  132. class="line-select"
  133. dictName="体积单位"
  134. clearable
  135. v-model="form.volumeUnit"
  136. >
  137. </DictSelection>
  138. </div>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="8">
  142. <el-form-item label="毛重">
  143. <div class="form-line">
  144. <el-input v-model="form.roughWeight" />
  145. </div>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="8">
  149. <el-form-item label="净重">
  150. <div class="form-line">
  151. <el-input v-model="form.netWeight" />
  152. </div>
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="8">
  156. <el-form-item label="级别">
  157. <template>
  158. <el-select
  159. style="width: 100%"
  160. v-model="form.level"
  161. placeholder="请选择"
  162. >
  163. <el-option
  164. v-for="item in levelOptions"
  165. :label="item.label"
  166. :value="item.value"
  167. :key="item.value"
  168. >
  169. </el-option>
  170. </el-select>
  171. </template>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
  175. <el-form-item :label="f.label">
  176. <template>
  177. <div class="form-line">
  178. <el-input v-model="form.extField[f.prop]" />
  179. </div>
  180. </template>
  181. </el-form-item>
  182. </el-col>
  183. </el-row>
  184. </el-form>
  185. </el-card>
  186. <!-- 自定义编码 -->
  187. <CodeDialog
  188. ref="codeRefs"
  189. v-if="codeShow"
  190. @close="codeShow = false"
  191. @chooseCode="chooseCode"
  192. ></CodeDialog>
  193. <!-- 分类选择弹窗 -->
  194. <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
  195. <!-- 仓储配置 -->
  196. <WarehouseInfo ref="warehouseRefs" :form="categoryWms" />
  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
  213. ref="linkMsgRef"
  214. :id="$route.query.id"
  215. :categoryLevelId="form.categoryLevelId"
  216. :categoryLevelGroupId="form.categoryLevelGroupId"
  217. />
  218. </div>
  219. </template>
  220. <script>
  221. import GroupDialog from './components/GroupDialog.vue';
  222. import CodeDialog from './components/codeDialog.vue';
  223. import CategoryDialog from './components/CategoryDialog.vue';
  224. import WarehouseInfo from './components/WarehouseInfo.vue';
  225. import ProcureInfo from './components/ProcureInfo.vue';
  226. import ProductionInfo from './components/ProductionInfo.vue';
  227. import PlanInfo from './components/PlanInfo.vue';
  228. import SalesInfo from './components/SalesInfo.vue';
  229. import QualityInfo from './components/QualityInfo.vue';
  230. import BoatInfo from './components/BoatInfo.vue';
  231. import TurnoverInfo from './components/TurnoverInfo.vue';
  232. import MoldInfo from './components/MoldInfo.vue';
  233. import RemarkInfo from './components/RemarkInfo.vue';
  234. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  235. import personSelect from '@/components/CommomSelect/person-select.vue';
  236. import linkMsg from './components/link-msg.vue';
  237. import { getDetails } from '@/api/classifyManage/itemInformation';
  238. import { getByCode } from '@/api/system/dictionary-data';
  239. import { getCode, rootCategoryCode, fieldModel } from '@/api/codeManagement';
  240. import { addMaterial } from '@/api/material/list.js';
  241. import { deepClone } from '@/utils/index';
  242. import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
  243. export default {
  244. name: 'ManageMaterial',
  245. components: {
  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. loading: false,
  266. levelOptions: [
  267. {
  268. label: '特级',
  269. value: '特级'
  270. },
  271. {
  272. label: '一级',
  273. value: '一级'
  274. },
  275. {
  276. label: '二级',
  277. value: '二级'
  278. },
  279. {
  280. label: '三级',
  281. value: '三级'
  282. }
  283. ],
  284. form: {
  285. categoryLevelGroupName: '',
  286. categoryLevelName: '',
  287. isConsumable: 1,
  288. extField: {}
  289. },
  290. remarkform: {
  291. remarkAttach: []
  292. },
  293. categoryAps: {},
  294. categoryMes: {},
  295. categoryMold: {},
  296. categoryPallet: {},
  297. categoryQms: {},
  298. categoryVehicle: {},
  299. categoryWms: {
  300. isUnpack: 1
  301. },
  302. categoryLevelPathId: null,
  303. dictList: [],
  304. fileList: [],
  305. // 表单验证规则
  306. rules: {
  307. categoryLevelGroupName: [
  308. { required: true, message: '请选择所属物料组', trigger: 'change' }
  309. ],
  310. code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
  311. name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  312. categoryLevelName: [
  313. { required: true, message: '请选择所属分类', trigger: 'change' }
  314. ],
  315. measuringUnit: [
  316. { required: true, message: '请选择计量单位', trigger: 'change' }
  317. ],
  318. weightUnit: [
  319. { required: true, message: '请选择重量单位', trigger: 'change' }
  320. ],
  321. packingUnit: [
  322. { required: true, message: '请选择包装单位', trigger: 'change' }
  323. ],
  324. netWeight: [
  325. { required: true, message: '请输入净重', trigger: 'blur' }
  326. ]
  327. },
  328. PathInfo: {},
  329. id: null,
  330. ruleCode: null,
  331. codeShow: false,
  332. status: null
  333. };
  334. },
  335. async created() {
  336. this.getFieldModel();
  337. this.status = this.$route.query.status;
  338. if (this.$route.query.id) {
  339. this._getDetails();
  340. }
  341. this.getDictList('productionType');
  342. },
  343. methods: {
  344. async _getDetails() {
  345. const data = await getDetails(this.$route.query.id);
  346. const info = deepClone(data);
  347. this.form = {
  348. ...info.category
  349. };
  350. let productType_ = this.form.produceType;
  351. if (productType_ != undefined && productType_ != null) {
  352. let intproductType = [];
  353. for (const [index, value] of productType_.entries()) {
  354. intproductType.push(value.toString());
  355. }
  356. this.form.produceType = intproductType;
  357. }
  358. this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
  359. this.judgeSet(info);
  360. if (this.status == 1) {
  361. rootCategoryCode(this.categoryLevelPathId).then((res) => {
  362. this.$set(this.form, 'code', res);
  363. });
  364. }
  365. this.$forceUpdate();
  366. },
  367. // 判断字段类型并赋值
  368. judgeSet(info) {
  369. if (typeof info.categoryAps == 'string') {
  370. this.categoryAps = {};
  371. } else {
  372. this.categoryAps = info.categoryAps;
  373. }
  374. if (typeof info.categoryMes == 'string') {
  375. this.categoryMes = {};
  376. } else {
  377. this.categoryMes = info.categoryMes;
  378. }
  379. if (typeof info.categoryMold == 'string') {
  380. this.categoryMold = {};
  381. } else {
  382. this.categoryMold = info.categoryMold;
  383. }
  384. if (typeof info.categoryPallet == 'string') {
  385. this.categoryPallet = {};
  386. } else {
  387. this.categoryPallet = info.categoryPallet;
  388. }
  389. if (typeof info.categoryQms == 'string') {
  390. this.categoryQms = {};
  391. } else {
  392. this.categoryQms = info.categoryQms;
  393. }
  394. if (typeof info.categoryVehicle == 'string') {
  395. this.categoryVehicle = {};
  396. } else {
  397. this.categoryVehicle = info.categoryVehicle;
  398. }
  399. if (typeof info.categoryWms == 'string') {
  400. this.categoryWms = {};
  401. } else {
  402. this.categoryWms = info.categoryWms;
  403. }
  404. },
  405. getFieldModel() {
  406. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  407. this.fileList = res;
  408. this.fileList.forEach((f) => {
  409. this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
  410. });
  411. });
  412. },
  413. // 确定分类
  414. async confirmCategory(node, title, PathInfo, ruleCode) {
  415. if (this.status != 0) {
  416. this.$set(this.form, 'code', null);
  417. }
  418. this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
  419. if (title == '选择产品分类') {
  420. this.$set(this.form, 'productCategoryLevelName', node.name);
  421. this.$set(this.form, 'productCategoryLevelId', node.id);
  422. } else {
  423. this.$set(this.form, 'categoryLevelName', node.name);
  424. this.$set(this.form, 'categoryLevelId', node.id);
  425. this.$set(this.form, 'categoryLevelPath', node.name);
  426. this.$set(this.form, 'categoryLevelPathId', node.id);
  427. this.PathInfo = PathInfo;
  428. this.ruleCode = ruleCode;
  429. if (ruleCode && ruleCode != '自定义' && this.status != 0) {
  430. const code = await getCode(ruleCode);
  431. this.$set(this.form, 'code', code);
  432. }
  433. }
  434. this.$forceUpdate();
  435. },
  436. async getDictList(code) {
  437. let { data: res } = await getByCode(code);
  438. this.dictList = res.map((item) => {
  439. let values = Object.keys(item);
  440. return {
  441. value: Number(values[0]),
  442. label: item[values[0]]
  443. };
  444. });
  445. },
  446. openCategory() {
  447. this.$refs.categoryRefs.open();
  448. },
  449. openCode() {
  450. this.codeShow = true;
  451. },
  452. chooseCode(code) {
  453. this.$set(this.form, 'code', code);
  454. this.codeShow = false;
  455. this.$forceUpdate();
  456. },
  457. cancel() {
  458. finishPageTab();
  459. this.$router.go(-1);
  460. },
  461. // 保存
  462. submit() {
  463. this.$refs.manageForm.validate((valid) => {
  464. if (!valid) {
  465. return false;
  466. }
  467. this.loading = true;
  468. // const imgList = this.remarkform.imgList;
  469. // const arr = [];
  470. // if (imgList.length) {
  471. // imgList.map((item) => {
  472. // arr.push(item.storePath);
  473. // });
  474. // this.form.remarkAttach = arr.join(',');
  475. // }
  476. // this.form.remark = this.remarkform.remark
  477. // ? this.remarkform.remark
  478. // : '';
  479. const data = {
  480. categoryWms: this.categoryWms,
  481. categoryAps: this.categoryAps,
  482. categoryMes: this.categoryMes,
  483. categoryMold: this.categoryMold,
  484. categoryPallet: this.categoryPallet,
  485. categoryQms: this.categoryQms,
  486. categoryVehicle: this.categoryVehicle,
  487. category: {
  488. ...this.form,
  489. ...this.remarkform,
  490. ...this.PathInfo
  491. }
  492. };
  493. if (this.$route.query.status == 1) {
  494. data.category.id = null;
  495. data.categoryWms.id = null;
  496. data.categoryAps.id = null;
  497. data.categoryMes.id = null;
  498. data.categoryMold.id = null;
  499. data.categoryPallet.id = null;
  500. data.categoryQms.id = null;
  501. data.categoryVehicle.id = null;
  502. }
  503. addMaterial(data)
  504. .then((msg) => {
  505. this.loading = false;
  506. this.$message.success(msg);
  507. reloadPageTab({ fullPath: '/material/product' });
  508. this.$router.go(-1);
  509. })
  510. .catch((e) => {
  511. this.loading = false;
  512. });
  513. });
  514. }
  515. }
  516. };
  517. </script>
  518. <style lang="scss" scoped>
  519. .ele-page-header {
  520. border: none;
  521. }
  522. .body-top {
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-between;
  526. background: #fff;
  527. .top-left {
  528. display: flex;
  529. align-items: center;
  530. justify-content: flex-start;
  531. margin-left: -25px;
  532. .el-form-item {
  533. margin-bottom: 0;
  534. }
  535. }
  536. }
  537. .divider {
  538. margin: 20px 0;
  539. .title {
  540. display: flex;
  541. align-items: center;
  542. margin-bottom: 10px;
  543. div {
  544. width: 8px;
  545. height: 20px;
  546. margin-right: 10px;
  547. }
  548. span {
  549. font-size: 20px;
  550. }
  551. }
  552. .ele-width {
  553. width: 100%;
  554. height: 2px;
  555. }
  556. }
  557. .form-line {
  558. display: flex;
  559. align-items: center;
  560. justify-content: space-between;
  561. .line-select {
  562. margin-left: 15px;
  563. }
  564. }
  565. </style>