edit.vue 14 KB

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