edit.vue 15 KB

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