edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="page-container equipment-container">
  3. <div class="basic-details-title">
  4. <span class="border-span">编辑周转车信息</span>
  5. <div>
  6. <el-button size="small" @click="$router.go(-1)">取消</el-button>
  7. <el-button size="small" type="primary" @click="toSave">确定</el-button>
  8. </div>
  9. </div>
  10. <div label-width="120px">
  11. <div class="content">
  12. <div class="basic-details-title border-none">
  13. <span class="border-span">基本信息</span>
  14. </div>
  15. <el-descriptions title="" :column="4" size="medium" border>
  16. <el-descriptions-item>
  17. <template slot="label"> 周转车编码 </template>
  18. {{ info.assetCode }}
  19. </el-descriptions-item>
  20. <el-descriptions-item>
  21. <template slot="label"> 周转车名称 </template>
  22. {{ info.assetName }}
  23. </el-descriptions-item>
  24. <el-descriptions-item>
  25. <template slot="label"> 材质 </template>
  26. {{ info.textureInfo.texture ? info.textureInfo.texture : '' }}
  27. </el-descriptions-item>
  28. <el-descriptions-item>
  29. <template slot="label"> 型号 </template>
  30. {{ info.information.modelType }}
  31. </el-descriptions-item>
  32. <el-descriptions-item :span="2">
  33. <template slot="label"> 分类 </template>
  34. {{ info.information.classificationUrl }}
  35. </el-descriptions-item>
  36. <el-descriptions-item>
  37. <template slot="label"> 采购日期 </template>
  38. {{ info.warehouseDetail.procurementTime }}
  39. </el-descriptions-item>
  40. <el-descriptions-item>
  41. <template slot="label"> 过保日期 </template>
  42. {{ info.warehouseDetail.expirationTime }}
  43. </el-descriptions-item>
  44. </el-descriptions>
  45. <div class="basic-details-title border-none">
  46. <span class="border-span">资产信息</span>
  47. </div>
  48. <el-form label-width="90px">
  49. <el-row>
  50. <el-col :md="8" :xs="8" :sm="8">
  51. <el-form-item label="固资编码" prop="fixAssetCode">
  52. <el-input
  53. v-model="info.fixAssetCode"
  54. type="text"
  55. size="small"
  56. placeholder="请输入"
  57. ></el-input
  58. ></el-form-item>
  59. </el-col>
  60. <el-col :md="8" :xs="8" :sm="8">
  61. <el-form-item label="权属部门" prop="name" class="qsbm">
  62. <el-input
  63. v-model="info.ownershipDeptCode"
  64. v-show="false"
  65. ></el-input>
  66. <!-- <selectTree
  67. ref="tree2"
  68. class="input"
  69. :value="info.ownershipDeptCode"
  70. :options="deptList"
  71. :props="{
  72. value: 'code',
  73. label: 'name',
  74. children: 'children'
  75. }"
  76. @getValue="qsDeptClick"
  77. /> -->
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </el-form>
  82. <div class="basic-details-title border-none">
  83. <span class="border-span">文档信息</span>
  84. </div>
  85. <div class="upload-container">
  86. <!-- <UploadImg
  87. @getImgs="cbUploadImg"
  88. :assetName="`周转车`"
  89. ref="UploadImg"
  90. /> -->
  91. </div>
  92. <div class="basic-details-title border-none">
  93. <span class="border-span">扩展信息</span>
  94. </div>
  95. <el-row>
  96. <el-form
  97. :model="itemForm"
  98. :rules="customRule"
  99. ref="formCustom"
  100. class="row-form"
  101. >
  102. <el-col
  103. :span="8"
  104. v-for="(item, index) in itemForm.addList"
  105. :key="index"
  106. >
  107. <el-form-item
  108. :prop="'addList.' + index + '.key'"
  109. :rules="{
  110. required: true,
  111. message: '自定义参数名称不能为空',
  112. trigger: 'blur'
  113. }"
  114. >
  115. <div class="add-col">
  116. <el-input
  117. class="col-input"
  118. v-model="item.key"
  119. placeholder="参数名称"
  120. ></el-input>
  121. <el-input
  122. class="col-input"
  123. v-model="item.value"
  124. placeholder="参数值"
  125. ></el-input>
  126. <el-button type="text" @click="delt(item, index)">
  127. 删除
  128. </el-button>
  129. </div>
  130. </el-form-item>
  131. </el-col>
  132. <el-col :span="8" v-if="itemForm.addList.length < 10">
  133. <el-form-item label-width="20px">
  134. <el-button type="primary" @click="addItem"
  135. >增加自定义参数</el-button
  136. >
  137. </el-form-item>
  138. </el-col>
  139. </el-form>
  140. </el-row>
  141. </div>
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. // import selectUpload from '@/components/selectUpload'
  147. // import UploadImg from '@/components/uploadImg/WithView.vue'
  148. // import {getAssetInfo,toSaveAsset} from "@/api/ledgerAssets/asset"
  149. // import { imageView } from "@/utils";
  150. // import org from "@/api/main/org";
  151. // import selectTree from "@/components/selectTree";
  152. import {
  153. getAssetInfo
  154. } from '@/api/ledgerAssets';
  155. export default {
  156. // components: { selectUpload, UploadImg , selectTree},
  157. data () {
  158. return {
  159. formData: {},
  160. info: {
  161. textureInfo: {},
  162. information: {},
  163. warehouseDetail: {},
  164. extendField: []
  165. },
  166. customRule: {},
  167. itemForm: {
  168. addList: []
  169. },
  170. imageUrl: null,
  171. deptList: []
  172. };
  173. },
  174. created () {
  175. let id = this.$route.query.id;
  176. this.getDetilInfo(id);
  177. // this.getTreeList();
  178. },
  179. methods: {
  180. // 树形结构数据
  181. // getTreeList () {
  182. // org.tree().then((res) => {
  183. // this.deptList = res.data;
  184. // });
  185. // },
  186. // 权属部门点击回调
  187. qsDeptClick (info) {
  188. this.info.ownershipDeptCode = info.code;
  189. this.info.ownershipDeptName = info.name;
  190. },
  191. async getDetilInfo (id) {
  192. const res = await getAssetInfo(id);
  193. if (res.success) {
  194. this.info = res.data;
  195. this.$set(this.info, 'information', res.data.information);
  196. this.$set(this.info, 'warehouseDetail', res.data.warehouseDetail);
  197. this.$set(
  198. this.info,
  199. 'textureInfo',
  200. JSON.parse(res.data.information.extendField)
  201. );
  202. this.$set(this.info, 'extendField', JSON.parse(res.data.extendField));
  203. // this.$set(this.info, 'imgUrl', res.data.imageUrl)
  204. this.itemForm.addList = this.info.extendField
  205. ? this.info.extendField
  206. : [];
  207. // 设备图片
  208. this.imageUrl = res.data.imageUrl;
  209. if (this.imageUrl) {
  210. imageView(this.imageUrl).then((res) => {
  211. this.$refs.UploadImg.setImg(res);
  212. });
  213. }
  214. }
  215. },
  216. // 删除自定义参数
  217. delt (item, index) {
  218. this.itemForm.addList.splice(index, 1);
  219. },
  220. // 添加自定义参数
  221. addItem () {
  222. if (this.itemForm.addList.length < 10) {
  223. let item = { key: '', value: '' };
  224. this.itemForm.addList.push(item);
  225. } else {
  226. this.$message.warning('自定义参数最多添加10条');
  227. }
  228. },
  229. // 选择图片回调
  230. cbUploadImg (data) {
  231. if (data.length > 0) {
  232. this.imageUrl = data[0];
  233. } else {
  234. this.imageUrl = '';
  235. }
  236. },
  237. // 点击确定保存
  238. toSave () {
  239. let extendField = this.itemForm.addList;
  240. let params = {
  241. id: this.info.id,
  242. assetCode: this.info.assetCode,
  243. imageUrl: this.imageUrl,
  244. extendField: JSON.stringify(extendField),
  245. fixAssetCode: this.info.fixAssetCode,
  246. isIotEnable: false,
  247. ownershipDeptCode: this.info.ownershipDeptCode,
  248. ownershipDeptName: this.info.ownershipDeptName
  249. };
  250. this.$refs['formCustom'].validate((valid) => {
  251. if (valid) {
  252. toSaveAsset(params).then((res) => {
  253. if (res.success) {
  254. this.$message.success('周转车编辑成功');
  255. this.$router.go(-1);
  256. }
  257. });
  258. } else {
  259. return false;
  260. }
  261. });
  262. }
  263. // //使用说明书
  264. // operatingManual (info) {
  265. // if (info.length > 0) {
  266. // console.log(info, '------info-----')
  267. // this.formData.operatingManual = info[0]
  268. // console.log(this.formData.operatingManual, 'getImgs')
  269. // } else {
  270. // this.formData.operatingManual = null
  271. // console.log(this.formData.operatingManual, 'getImgs')
  272. // }
  273. // },
  274. // productionLicence (info) {
  275. // this.formData.productionLicence = info[0]
  276. // },
  277. // explosionProofCertificate (info) {
  278. // this.formData.explosionProofCertificate = info[0]
  279. // },
  280. // surveyReport (info) {
  281. // this.formData.surveyReport = info[0]
  282. // },
  283. // inspectionCycleManual (info) {
  284. // this.formData.inspectionCycleManual = info[0]
  285. // },
  286. // informationDrawing (info) {
  287. // this.formData.informationDrawing = info[0]
  288. // },
  289. // productCertificate (info) {
  290. // this.formData.productCertificate = info[0]
  291. // }
  292. }
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. .equipment-container {
  297. background-color: #fff;
  298. padding: 20px;
  299. .basic-details-title {
  300. width: 100%;
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. margin: 15px 0px;
  305. font-size: 16px;
  306. }
  307. .basic-details-title:first-child {
  308. margin: 0px 0px 15px;
  309. }
  310. .content {
  311. padding: 0 20px;
  312. }
  313. .label-none {
  314. .el-form-item__content {
  315. margin-left: 0 !important;
  316. }
  317. }
  318. .upload-container {
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. // .file-list {
  323. // margin-left: 50px;
  324. // flex: 1;
  325. // }
  326. }
  327. .el-form-item__content {
  328. display: flex;
  329. }
  330. .row-form {
  331. width: 100%;
  332. .add-col {
  333. display: flex;
  334. align-items: center;
  335. margin-left: 20px;
  336. .col-input {
  337. margin-right: 5px;
  338. }
  339. }
  340. }
  341. .qsbm .el-select {
  342. width: 100%;
  343. }
  344. }
  345. </style>