edit copy.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <div class="ele-body">
  3. <el-card :body-style="{ padding: 0 }">
  4. <div class="page-container equipment-container">
  5. <div class="page-title basic-details-title">
  6. <el-page-header @back="$router.go(-1)">
  7. <div slot="content" class="pageContent">
  8. <div>{{ title }}</div>
  9. </div>
  10. </el-page-header>
  11. <div>
  12. <!-- <el-button size="small" @click="$router.go(-1)">取消</el-button> -->
  13. <el-button
  14. size="small"
  15. type="primary"
  16. @click="toSave"
  17. v-loading="btnLoading"
  18. >确定</el-button
  19. >
  20. </div>
  21. </div>
  22. <div v-if="pageType == 'add'">
  23. <el-button type="primary" plain @click="handlwpbm"
  24. >选择物品</el-button
  25. >
  26. </div>
  27. <div label-width="120px">
  28. <div class="content">
  29. <basicInfoVue ref="basicInfoRef" />
  30. <businessInformation ref="businessInformationRef" :form="info" />
  31. <assetInformation ref="assetInformationRef" :form="info" />
  32. <!-- <div class="basic-details-title border-none">
  33. <span class="border-span">资产信息</span>
  34. </div>
  35. <el-form label-width="90px">
  36. <el-descriptions
  37. title=""
  38. :column="4"
  39. size="medium"
  40. border
  41. style="edit"
  42. >
  43. <el-descriptions-item>
  44. <template slot="label"> 固资编码 </template>
  45. <el-form-item label-width="0">
  46. <el-input class="input" v-model="info.fixCode"></el-input>
  47. </el-form-item>
  48. </el-descriptions-item>
  49. <el-descriptions-item>
  50. <template slot="label"> 编号 </template>
  51. <el-form-item label-width="0">
  52. <el-input
  53. class="input"
  54. v-model="info.codeNumber"
  55. ></el-input>
  56. </el-form-item>
  57. </el-descriptions-item>
  58. <el-descriptions-item>
  59. <template slot="label"> 权属部门 </template>
  60. <el-form-item label-width="0">
  61. <ele-tree-select
  62. clearable
  63. :data="treeData"
  64. v-model="info.ownershipGroupId"
  65. placeholder="请选择"
  66. default-expand-all
  67. labelKey="name"
  68. valueKey="id"
  69. />
  70. </el-form-item>
  71. </el-descriptions-item>
  72. </el-descriptions>
  73. </el-form> -->
  74. <div class="basic-details-title border-none">
  75. <span class="border-span">周转车信息</span>
  76. </div>
  77. <el-descriptions
  78. :label-style="labelStyle"
  79. :contentStyle="contentStyle"
  80. title=""
  81. :column="3"
  82. size="medium"
  83. border
  84. >
  85. <el-descriptions-item>
  86. <template slot="label">长</template>
  87. {{
  88. categoryVehicle.vehicleLen
  89. ? categoryVehicle.vehicleLen + 'mm'
  90. : null
  91. }}
  92. </el-descriptions-item>
  93. <el-descriptions-item>
  94. <template slot="label">宽</template>
  95. {{
  96. categoryVehicle.wilde ? categoryVehicle.wilde + 'mm' : null
  97. }}
  98. </el-descriptions-item>
  99. <el-descriptions-item>
  100. <template slot="label">高</template>
  101. {{
  102. categoryVehicle.hight ? categoryVehicle.hight + 'mm' : null
  103. }}
  104. </el-descriptions-item>
  105. <el-descriptions-item>
  106. <template slot="label">层数</template>
  107. {{ categoryVehicle.levelNum }}
  108. </el-descriptions-item>
  109. <el-descriptions-item>
  110. <template slot="label">材质</template>
  111. {{ categoryVehicle.materialQuality }}
  112. </el-descriptions-item>
  113. </el-descriptions>
  114. <div class="baseinfo-container">
  115. <warehouseConfigVue ref="warehouseConfigRef" class="ims" />
  116. <productInfoVue ref="productInfoRef" />
  117. <planVue ref="planRef" />
  118. <qualityConfig ref="qualityConfigRef" />
  119. <footerVue ref="footerVueRef" />
  120. </div>
  121. <div class="basic-details-title border-none">
  122. <span class="border-span">文档信息</span>
  123. </div>
  124. <div class="upload-container">
  125. <WithView v-model="imageUrl" :limit="1" :assetName="'周转车'" />
  126. </div>
  127. <div class="basic-details-title border-none">
  128. <span class="border-span">扩展信息</span>
  129. </div>
  130. <el-row>
  131. <el-form
  132. :model="itemForm"
  133. :rules="customRule"
  134. ref="formCustom"
  135. class="row-form"
  136. >
  137. <el-col
  138. :span="8"
  139. v-for="(item, index) in itemForm.addList"
  140. :key="index"
  141. >
  142. <el-form-item
  143. :prop="'addList.' + index + '.key'"
  144. :rules="{
  145. required: true,
  146. message: '自定义参数名称不能为空',
  147. trigger: 'blur'
  148. }"
  149. >
  150. <div class="add-col">
  151. <el-input
  152. class="col-input"
  153. v-model="item.key"
  154. placeholder="参数名称"
  155. ></el-input>
  156. <el-input
  157. class="col-input"
  158. v-model="item.value"
  159. placeholder="参数值"
  160. ></el-input>
  161. <el-button type="text" @click="delt(item, index)">
  162. 删除
  163. </el-button>
  164. </div>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="8" v-if="itemForm.addList.length < 10">
  168. <el-form-item label-width="20px">
  169. <el-button type="primary" @click="addItem"
  170. >增加自定义参数</el-button
  171. >
  172. </el-form-item>
  173. </el-col>
  174. </el-form>
  175. </el-row>
  176. </div>
  177. </div>
  178. </div>
  179. <DialogGoods
  180. ref="DialogGoods"
  181. @succeed="cbDialogGoods"
  182. width="1200px"
  183. ></DialogGoods>
  184. </el-card>
  185. </div>
  186. </template>
  187. <script>
  188. import DialogGoods from '../components/DialogGoods';
  189. import {
  190. getAssetInfo,
  191. saveOrEdit,
  192. getCode,
  193. getAssetNum
  194. } from '@/api/ledgerAssets';
  195. import { listOrganizations } from '@/api/system/organization';
  196. import WithView from '@/components/upload/WithView';
  197. import dictMixins from '@/mixins/dictMixins';
  198. import { getDetails } from '@/api/classifyManage/itemInformation';
  199. import { sysDict } from '@/utils/sys';
  200. import basicInfoVue from '../components/basicInfo.vue';
  201. import businessInformation from '../components/businessInformation.vue';
  202. import assetInformation from '../components/assetInformation.vue';
  203. import warehouseConfigVue from '../components/warehouseConfig.vue';
  204. import productInfoVue from '../components/productInfo.vue';
  205. import planVue from '../components/plan.vue';
  206. import qualityConfig from '../components/qualityConfig.vue';
  207. import footerVue from '../components/footer.vue';
  208. export default {
  209. mixins: [dictMixins],
  210. components: {
  211. WithView,
  212. basicInfoVue,
  213. warehouseConfigVue,
  214. productInfoVue,
  215. planVue,
  216. qualityConfig,
  217. footerVue,
  218. assetInformation,
  219. businessInformation,
  220. DialogGoods
  221. },
  222. data() {
  223. return {
  224. labelStyle: {
  225. width: '200px'
  226. },
  227. contentStyle: {
  228. width: '400px'
  229. },
  230. formData: {},
  231. info: {
  232. category: {},
  233. warehouseDetail: {}
  234. },
  235. customRule: {},
  236. itemForm: {
  237. addList: []
  238. },
  239. imageUrl: {},
  240. treeData: [],
  241. btnLoading: false,
  242. categoryVehicle: {},
  243. // 基本信息
  244. basicInfo: {},
  245. id: '',
  246. pageType: '',
  247. title: ''
  248. };
  249. },
  250. async created() {
  251. this.requestDict('周转车材质');
  252. if (this.$route.query.id) {
  253. this.pageType = 'edit';
  254. this.id = this.$route.query.id;
  255. await this.getInfo();
  256. this.title = '编辑周转车信息';
  257. // this.getgys();
  258. // await this._getWarehouseChildren();
  259. } else {
  260. this.pageType = 'add';
  261. this.title = '新增周转车信息';
  262. }
  263. // let id = this.$route.query.id;
  264. // this.getDetilInfo(id);
  265. // this.query();
  266. },
  267. methods: {
  268. handlwpbm() {
  269. this.$refs.DialogGoods.open('7');
  270. },
  271. async cbDialogGoods(data) {
  272. // this.searchMoudol(data.category.category.id);
  273. let res = await getDetails(data.id);
  274. console.log(res);
  275. if (!data.extInfoSelf) {
  276. data.extInfoSelf = [];
  277. }
  278. if (!data.workstation) {
  279. data.workstation = {};
  280. }
  281. this.info = data;
  282. this.info.category = res;
  283. this.basicInfo = data;
  284. console.log('this.basicInfo-----------');
  285. console.log(this.basicInfo);
  286. if (typeof this.basicInfo.categoryLevelPathId === 'string') {
  287. let categoryLevelPathId = JSON.parse(
  288. this.basicInfo.categoryLevelPathId
  289. );
  290. if (Array.isArray(categoryLevelPathId)) {
  291. this.info.rootCategoryLevelId = JSON.parse(
  292. this.basicInfo.categoryLevelPathId
  293. )[0];
  294. } else {
  295. this.info.rootCategoryLevelId = categoryLevelPathId;
  296. }
  297. } else {
  298. if (Array.isArray(this.info.rootCategoryLevelId)) {
  299. this.info.rootCategoryLevelId =
  300. this.basicInfo.categoryLevelPathId[0];
  301. } else {
  302. this.info.rootCategoryLevelId = this.basicInfo.categoryLevelPathId;
  303. }
  304. }
  305. this.info.categoryId = this.basicInfo.id;
  306. this.info.name = this.basicInfo.name;
  307. this.info.code = data.code; //Date.now(); //res.data[0].onlyCode;
  308. this.$nextTick(() => {
  309. this.$refs.basicInfoRef.getDetailInfoAugr(
  310. this.info.category.category
  311. );
  312. this.$refs.warehouseConfigRef.getDetailInfoAugr(
  313. this.info.category.categoryWms
  314. );
  315. this.$refs.productInfoRef.getDetailInfoAugr(
  316. this.info.category.categoryMes
  317. );
  318. this.$refs.planRef.getDetailInfoAugr(this.info.category.categoryAps);
  319. this.$refs.qualityConfigRef.getDetailInfoAugr(
  320. this.info.category.categoryQms
  321. );
  322. this.$refs.footerVueRef.getDetailInfoAugr(
  323. this.info.category.category
  324. );
  325. });
  326. },
  327. // 树形结构数据
  328. query() {
  329. listOrganizations()
  330. .then((list) => {
  331. this.treeData = this.$util.toTreeData({
  332. data: list,
  333. idField: 'id',
  334. parentIdField: 'parentId'
  335. });
  336. })
  337. .catch((e) => {});
  338. },
  339. async getInfo() {
  340. const res = await getAssetInfo(this.id);
  341. if (res) {
  342. if (!res.workstation) {
  343. res.workstation = {};
  344. }
  345. this.info = res;
  346. this.$set(this.info, 'location', res.deviceLocationName.split(',')); //位置信息
  347. this.$set(this.info, 'category', res.category);
  348. this.itemForm.addList = this.info.extInfoSelf
  349. ? this.info.extInfoSelf
  350. : [];
  351. // 设备图片
  352. this.imageUrl = res.imageUrl ? res.imageUrl : {};
  353. const rep = await getDetails(res.categoryId);
  354. console.log('rep------------------------');
  355. console.log(rep);
  356. this.$nextTick(() => {
  357. this.$refs.basicInfoRef.getDetailInfoAugr(rep.category);
  358. this.$refs.warehouseConfigRef.getDetailInfoAugr(rep.categoryWms);
  359. this.$refs.productInfoRef.getDetailInfoAugr(rep.categoryMes);
  360. this.$refs.planRef.getDetailInfoAugr(rep.categoryAps);
  361. this.$refs.qualityConfigRef.getDetailInfoAugr(rep.categoryQms);
  362. this.$refs.footerVueRef.getDetailInfoAugr(rep.category);
  363. });
  364. this.categoryVehicle = {
  365. ...rep.categoryVehicle,
  366. materialQuality: await sysDict(
  367. '周转车材质',
  368. rep.categoryVehicle.materialQuality
  369. )
  370. };
  371. }
  372. },
  373. // 删除自定义参数
  374. delt(item, index) {
  375. this.itemForm.addList.splice(index, 1);
  376. },
  377. // 添加自定义参数
  378. addItem() {
  379. if (this.itemForm.addList.length < 10) {
  380. let item = { key: '', value: '' };
  381. this.itemForm.addList.push(item);
  382. } else {
  383. this.$message.warning('自定义参数最多添加10条');
  384. }
  385. },
  386. // 选择图片回调
  387. cbUploadImg(data) {
  388. if (data.length > 0) {
  389. this.imageUrl = data[0];
  390. } else {
  391. this.imageUrl = '';
  392. }
  393. },
  394. // 点击确定保存
  395. async toSave() {
  396. if (JSON.stringify(this.basicInfo) === '{}' && this.pageType == 'add') {
  397. return this.$message.error('请选择物品编码');
  398. }
  399. let extendField = this.itemForm.addList;
  400. let params = {
  401. ...this.info,
  402. id: this.info.id,
  403. code: this.info.code,
  404. fixCode: this.info.fixCode,
  405. imageUrl: this.imageUrl || {},
  406. extInfoSelf: extendField,
  407. ownershipGroupId: this.info.ownershipGroupId,
  408. rootCategoryLevelId: this.info.rootCategoryLevelId,
  409. categoryId: this.info.categoryId,
  410. deviceLocationName: this.info.location
  411. ? this.info.location.join(',')
  412. : '',
  413. positionIds: '1,1,1,1',
  414. position: {
  415. type: '1',
  416. num: 1
  417. }
  418. // positionIds: typeof this.info.category.categoryLevelPathId == 'string'? this.info.category.categoryLevelPathId : JSON.parse(this.info.category.categoryLevelPathId).join(',')
  419. };
  420. //============================
  421. params.extInfo = {
  422. ownershipGroupId: this.info.ownershipGroupId,
  423. fixCode: this.info.fixCode,
  424. codeNumber: this.info.codeNumber
  425. };
  426. let obj = {};
  427. params.extInfoSelf.forEach((item) => {
  428. obj[item.key] = item.value;
  429. });
  430. params.extInfoSelf = obj;
  431. params = { ...params, ...params.extInfo };
  432. //============================
  433. if (this.pageType == 'add') {
  434. const batchNo = await getCode('lot_number_code');
  435. const res = await getAssetNum({
  436. assetCode: params.code,
  437. batchNum: batchNo,
  438. num: 1
  439. });
  440. params.code = res.data.shift().onlyCode;
  441. params.id = '';
  442. }
  443. this.btnLoading = true;
  444. this.$refs['formCustom'].validate((valid) => {
  445. if (valid) {
  446. saveOrEdit(params)
  447. .then((res) => {
  448. if (res) {
  449. this.$message.success('周转车编辑成功');
  450. this.$router.go(-1);
  451. }
  452. })
  453. .finally(() => {
  454. this.btnLoading = false;
  455. });
  456. } else {
  457. return false;
  458. }
  459. });
  460. }
  461. // //使用说明书
  462. // operatingManual (info) {
  463. // if (info.length > 0) {
  464. // console.log(info, '------info-----')
  465. // this.formData.operatingManual = info[0]
  466. // console.log(this.formData.operatingManual, 'getImgs')
  467. // } else {
  468. // this.formData.operatingManual = null
  469. // console.log(this.formData.operatingManual, 'getImgs')
  470. // }
  471. // },
  472. // productionLicence (info) {
  473. // this.formData.productionLicence = info[0]
  474. // },
  475. // explosionProofCertificate (info) {
  476. // this.formData.explosionProofCertificate = info[0]
  477. // },
  478. // surveyReport (info) {
  479. // this.formData.surveyReport = info[0]
  480. // },
  481. // inspectionCycleManual (info) {
  482. // this.formData.inspectionCycleManual = info[0]
  483. // },
  484. // informationDrawing (info) {
  485. // this.formData.informationDrawing = info[0]
  486. // },
  487. // productCertificate (info) {
  488. // this.formData.productCertificate = info[0]
  489. // }
  490. }
  491. };
  492. </script>
  493. <style lang="scss" scoped>
  494. .equipment-container {
  495. background-color: #fff;
  496. padding: 20px;
  497. .page-title {
  498. width: 100%;
  499. padding-bottom: 10px;
  500. border-bottom: 1px solid #ccc;
  501. }
  502. .basic-details-title {
  503. width: 100%;
  504. display: flex;
  505. align-items: center;
  506. justify-content: space-between;
  507. margin: 15px 0px;
  508. font-size: 16px;
  509. }
  510. .basic-details-title:first-child {
  511. margin: 0px 0px 15px;
  512. }
  513. .content {
  514. padding: 0 20px;
  515. }
  516. .label-none {
  517. .el-form-item__content {
  518. margin-left: 0 !important;
  519. }
  520. }
  521. .upload-container {
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. // .file-list {
  526. // margin-left: 50px;
  527. // flex: 1;
  528. // }
  529. }
  530. .el-form-item__content {
  531. display: flex;
  532. }
  533. .row-form {
  534. width: 100%;
  535. .add-col {
  536. display: flex;
  537. align-items: center;
  538. margin-left: 20px;
  539. .col-input {
  540. margin-right: 5px;
  541. }
  542. }
  543. }
  544. .qsbm .el-select {
  545. width: 100%;
  546. }
  547. }
  548. ::v-deep .el-descriptions {
  549. .el-form-item {
  550. margin-bottom: 0px;
  551. }
  552. }
  553. </style>