edit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  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>编辑备品备件信息</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 class="content">
  23. <el-form label-width="120px">
  24. <basicInfoVue ref="basicInfoRef" />
  25. <div class="basic-details-title border-none">
  26. <span class="border-span">资产信息</span>
  27. </div>
  28. <el-descriptions
  29. title=""
  30. :column="4"
  31. size="medium"
  32. border
  33. style="edit"
  34. >
  35. <el-descriptions-item>
  36. <template slot="label"> 固资编码 </template>
  37. <el-form-item label-width="0">
  38. <el-input size="small" v-model="info.fixCode"></el-input>
  39. </el-form-item>
  40. </el-descriptions-item>
  41. <el-descriptions-item>
  42. <template slot="label"> 编号 </template>
  43. <el-form-item label-width="0">
  44. <el-input size="small" v-model="info.codeNumber"></el-input>
  45. </el-form-item>
  46. </el-descriptions-item>
  47. <el-descriptions-item>
  48. <template slot="label"> 权属部门 </template>
  49. <el-form-item label-width="0">
  50. <ele-tree-select
  51. clearable
  52. :data="treeData"
  53. v-model="info.ownershipGroupId"
  54. placeholder="请选择"
  55. default-expand-all
  56. labelKey="name"
  57. valueKey="id"
  58. />
  59. </el-form-item>
  60. </el-descriptions-item>
  61. </el-descriptions>
  62. <div class="baseinfo-container">
  63. <warehouseConfigVue ref="warehouseConfigRef" />
  64. <productInfoVue ref="productInfoRef" />
  65. <planVue ref="planRef" />
  66. <qualityConfig ref="qualityConfigRef" />
  67. <footerVue ref="footerVueRef" />
  68. </div>
  69. <div class="basic-details-title border-none">
  70. <span class="border-span">文档信息</span>
  71. </div>
  72. <div class="upload-container">
  73. <WithView v-model="imageUrl" :limit="1" :assetName="'备品备件'" />
  74. <div class="file-list">
  75. <div>
  76. <el-form-item prop="image" label="使用说明书">
  77. <fileUpload
  78. v-model="attUrl.operatingManual.value"
  79. module="main"
  80. :showLib="true"
  81. />
  82. </el-form-item>
  83. </div>
  84. <div>
  85. <el-form-item prop="image" label="生产许可证书">
  86. <fileUpload
  87. v-model="attUrl.productionLicence.value"
  88. module="main"
  89. :showLib="true"
  90. />
  91. </el-form-item>
  92. </div>
  93. <div>
  94. <el-form-item prop="image" label="防爆合格证书">
  95. <fileUpload
  96. v-model="attUrl.explosionProofCertificate.value"
  97. module="main"
  98. :showLib="true"
  99. />
  100. </el-form-item>
  101. </div>
  102. <div>
  103. <el-form-item prop="image" label="检验报告">
  104. <fileUpload
  105. v-model="attUrl.surveyReport.value"
  106. module="main"
  107. :showLib="true"
  108. />
  109. </el-form-item>
  110. </div>
  111. <div>
  112. <el-form-item prop="image" label="检验周期说明">
  113. <fileUpload
  114. v-model="attUrl.inspectionCycleManual.value"
  115. module="main"
  116. :showLib="true"
  117. />
  118. </el-form-item>
  119. </div>
  120. <div>
  121. <el-form-item prop="image" label="图纸资料">
  122. <fileUpload
  123. v-model="attUrl.informationDrawing.value"
  124. module="main"
  125. :showLib="true"
  126. />
  127. </el-form-item>
  128. </div>
  129. <div>
  130. <el-form-item prop="image" label="产品合格证">
  131. <fileUpload
  132. v-model="attUrl.productCertificate.value"
  133. module="main"
  134. :showLib="true"
  135. />
  136. </el-form-item>
  137. </div>
  138. </div>
  139. </div>
  140. </el-form>
  141. <div class="basic-details-title border-none">
  142. <span class="border-span">扩展信息</span>
  143. </div>
  144. <el-row>
  145. <el-form
  146. :model="itemForm"
  147. :rules="customRule"
  148. ref="formCustom"
  149. class="row-form"
  150. >
  151. <el-col
  152. :span="8"
  153. v-for="(item, index) in itemForm.addList"
  154. :key="index"
  155. >
  156. <el-form-item
  157. :prop="'addList.' + index + '.key'"
  158. :rules="{
  159. required: true,
  160. message: '自定义参数名称不能为空',
  161. trigger: 'blur'
  162. }"
  163. >
  164. <div class="add-col">
  165. <el-input
  166. class="col-input"
  167. v-model="item.key"
  168. placeholder="参数名称"
  169. ></el-input>
  170. <el-input
  171. class="col-input"
  172. v-model="item.value"
  173. placeholder="参数值"
  174. ></el-input>
  175. <el-button type="text" @click="delt(item, index)">
  176. 删除
  177. </el-button>
  178. </div>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="8" v-if="itemForm.addList.length < 10">
  182. <el-form-item label-width="20px">
  183. <el-button type="primary" @click="addItem"
  184. >增加自定义参数</el-button
  185. >
  186. </el-form-item>
  187. </el-col>
  188. </el-form>
  189. </el-row>
  190. </div>
  191. </div>
  192. </el-card>
  193. </div>
  194. </template>
  195. <script>
  196. import fileUpload from '@/components/upload/fileUpload';
  197. import WithView from '@/components/upload/WithView';
  198. import imgUpload from '@/components/upload/imgUpload';
  199. import { getAssetInfo, saveOrEdit } from '@/api/ledgerAssets';
  200. import { listOrganizations } from '@/api/system/organization';
  201. import basicInfoVue from '../components/basicInfo.vue';
  202. import warehouseConfigVue from '../components/warehouseConfig.vue';
  203. import productInfoVue from '../components/productInfo.vue';
  204. import planVue from '../components/plan.vue';
  205. import qualityConfig from '../components/qualityConfig.vue';
  206. import footerVue from '../components/footer.vue';
  207. import { getDetails } from '@/api/classifyManage/itemInformation';
  208. export default {
  209. components: {
  210. WithView,
  211. fileUpload,
  212. imgUpload,
  213. basicInfoVue,
  214. warehouseConfigVue,
  215. productInfoVue,
  216. planVue,
  217. qualityConfig,
  218. footerVue
  219. },
  220. data() {
  221. return {
  222. formData: {},
  223. info: {
  224. baseInfo: {},
  225. extraInfo: {}
  226. },
  227. customRule: {},
  228. itemForm: {
  229. addList: []
  230. },
  231. // 图片
  232. imageUrl: null,
  233. // 文档信息
  234. attUrl: {
  235. operatingManual: {
  236. value: [],
  237. sort: 1
  238. },
  239. productionLicence: {
  240. value: [],
  241. sort: 2
  242. },
  243. explosionProofCertificate: {
  244. value: [],
  245. sort: 3
  246. },
  247. surveyReport: {
  248. value: [],
  249. sort: 4
  250. },
  251. inspectionCycleManual: {
  252. value: [],
  253. sort: 5
  254. },
  255. informationDrawing: {
  256. value: [],
  257. sort: 6
  258. },
  259. productCertificate: {
  260. value: [],
  261. sort: 7
  262. }
  263. },
  264. treeData: [],
  265. btnLoading: false
  266. };
  267. },
  268. created() {
  269. let id = this.$route.query.id;
  270. this.getDetilInfo(id);
  271. this.query();
  272. },
  273. methods: {
  274. // 树形结构数据
  275. query() {
  276. listOrganizations()
  277. .then((list) => {
  278. this.treeData = this.$util.toTreeData({
  279. data: list,
  280. idField: 'id',
  281. parentIdField: 'parentId'
  282. });
  283. })
  284. .catch((e) => {});
  285. },
  286. setImgs(type, sort, info) {
  287. if (info[0]) {
  288. this.attUrl[type] = info[0];
  289. this.attUrl[type].sort = sort;
  290. } else {
  291. this.attUrl[type] = null;
  292. }
  293. },
  294. // 处理文档信息
  295. setWd() {
  296. let attUrl = [];
  297. Object.entries(this.attUrl).forEach(([key, value], index) => {
  298. if (value) {
  299. attUrl.push(value);
  300. } else {
  301. attUrl.push({ sort: index + 1 });
  302. }
  303. });
  304. return attUrl;
  305. },
  306. // 选择图片回调
  307. cbUploadImg(data) {
  308. if (data.length > 0) {
  309. this.imageUrl = data[0];
  310. } else {
  311. this.imageUrl = '';
  312. }
  313. },
  314. async getDetilInfo(id) {
  315. const data = await getAssetInfo(id);
  316. if (data) {
  317. this.info = data;
  318. this.$set(this.info, 'baseInfo', data.category.category);
  319. this.$set(this.info, 'extraInfo', data.category.extendField);
  320. this.itemForm.addList = this.info.extInfoSelf
  321. ? this.info.extInfoSelf
  322. : [];
  323. if (data.attUrl && data.attUrl.length > 0) {
  324. // 文档信息
  325. Object.keys(this.attUrl).forEach((n, index) => {
  326. this.attUrl[n].value =
  327. (data.attUrl[index]?.storePath && [data.attUrl[index]]) || [];
  328. });
  329. }
  330. // 设备图片
  331. this.imageUrl = data.imageUrl || {};
  332. const rep = await getDetails(data.categoryId);
  333. console.log('==', rep);
  334. this.$nextTick(() => {
  335. this.$refs.basicInfoRef.getDetailInfoAugr(rep.category);
  336. this.$refs.warehouseConfigRef.getDetailInfoAugr(rep.categoryWms);
  337. this.$refs.productInfoRef.getDetailInfoAugr(rep.categoryMes);
  338. this.$refs.planRef.getDetailInfoAugr(rep.categoryAps);
  339. this.$refs.qualityConfigRef.getDetailInfoAugr(rep.categoryQms);
  340. this.$refs.footerVueRef.getDetailInfoAugr(rep.category);
  341. });
  342. }
  343. },
  344. // 删除自定义参数
  345. delt(item, index) {
  346. this.itemForm.addList.splice(index, 1);
  347. },
  348. // 添加自定义参数
  349. addItem() {
  350. if (this.itemForm.addList.length < 10) {
  351. let item = { key: '', value: '' };
  352. this.itemForm.addList.push(item);
  353. } else {
  354. this.$message.warning('自定义参数最多添加10条');
  355. }
  356. },
  357. // 处理文档信息
  358. setWd() {
  359. return Object.values(this.attUrl).map((item) => ({
  360. ...(item.value[0] || {}),
  361. sort: item.sort
  362. }));
  363. },
  364. // 点击确定保存
  365. toSave() {
  366. let extendField = this.itemForm.addList;
  367. let params = {
  368. id: this.info.id,
  369. code: this.info.code,
  370. fixCode: this.info.fixCode,
  371. imageUrl: this.imageUrl || {},
  372. extInfoSelf: extendField,
  373. ownershipGroupId: this.info.ownershipGroupId,
  374. rootCategoryLevelId: this.info.rootCategoryLevelId,
  375. categoryId: this.info.categoryId,
  376. position:
  377. typeof this.info.positionList == 'string'
  378. ? {}
  379. : this.info.positionList[0],
  380. // 文档信息
  381. attUrl: this.setWd() || []
  382. // positionIds: JSON.parse(this.info.category.categoryLevelPathId).join(',')
  383. };
  384. this.btnLoading = true;
  385. this.$refs['formCustom'].validate((valid) => {
  386. if (valid) {
  387. saveOrEdit(params)
  388. .then((res) => {
  389. if (res) {
  390. this.$message.success('备品备件编辑成功');
  391. this.$router.go(-1);
  392. }
  393. })
  394. .finally(() => {
  395. this.btnLoading = false;
  396. });
  397. } else {
  398. return false;
  399. }
  400. });
  401. }
  402. }
  403. };
  404. </script>
  405. <style lang="scss" scoped>
  406. .equipment-container {
  407. background-color: #fff;
  408. .content {
  409. padding: 0 20px;
  410. }
  411. .label-none {
  412. .el-form-item__content {
  413. margin-left: 0 !important;
  414. }
  415. }
  416. .page-title {
  417. width: 100%;
  418. padding-bottom: 10px;
  419. border-bottom: 1px solid #ccc;
  420. }
  421. .basic-details-title {
  422. width: 100%;
  423. display: flex;
  424. align-items: center;
  425. justify-content: space-between;
  426. margin: 15px 0px;
  427. font-size: 16px;
  428. }
  429. .upload-container {
  430. display: flex;
  431. .file-list {
  432. margin-left: 50px;
  433. flex: 1;
  434. }
  435. }
  436. .row-form {
  437. width: 100%;
  438. .add-col {
  439. display: flex;
  440. align-items: center;
  441. margin-left: 20px;
  442. .col-input {
  443. margin-right: 5px;
  444. }
  445. }
  446. }
  447. .qsbm .el-select {
  448. width: 100%;
  449. }
  450. }
  451. ::v-deep .el-descriptions {
  452. .el-form-item {
  453. margin-bottom: 0px;
  454. }
  455. }
  456. </style>