edit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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 label-width="120px">
  21. <div class="content">
  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. {{getDictValue('周转车材质', info.category.materialQuality)}}
  37. <!-- {{ info.category.extendField && JSON.parse(info.category.extendField).texture }} -->
  38. </el-descriptions-item>
  39. <el-descriptions-item>
  40. <template slot="label"> 型号 </template>
  41. {{ info.category.modelType }}
  42. </el-descriptions-item>
  43. <el-descriptions-item :span="2">
  44. <template slot="label"> 分类 </template>
  45. {{ info.category.categoryLevelPath }}
  46. </el-descriptions-item>
  47. <el-descriptions-item>
  48. <template slot="label"> 采购日期 </template>
  49. <!-- {{ info.warehouseDetail.procurementTime }} -->
  50. </el-descriptions-item>
  51. <el-descriptions-item>
  52. <template slot="label"> 过保日期 </template>
  53. <!-- {{ info.warehouseDetail.expirationTime }} -->
  54. </el-descriptions-item>
  55. </el-descriptions>
  56. <div class="basic-details-title border-none">
  57. <span class="border-span">资产信息</span>
  58. </div>
  59. <el-form label-width="90px">
  60. <el-row>
  61. <el-col :md="8" :xs="8" :sm="8">
  62. <el-form-item label="固资编码" prop="fixCode">
  63. <el-input
  64. v-model="info.fixCode"
  65. type="text"
  66. size="small"
  67. placeholder="请输入"
  68. ></el-input
  69. ></el-form-item>
  70. </el-col>
  71. <el-col :md="8" :xs="8" :sm="8">
  72. <el-form-item label="权属部门" prop="name" class="qsbm">
  73. <ele-tree-select
  74. clearable
  75. :data="treeData"
  76. v-model="info.ownershipGroupId"
  77. placeholder="请选择"
  78. default-expand-all
  79. labelKey="name"
  80. valueKey="id"
  81. />
  82. </el-form-item>
  83. </el-col>
  84. </el-row>
  85. </el-form>
  86. <div class="basic-details-title border-none">
  87. <span class="border-span">文档信息</span>
  88. </div>
  89. <div class="upload-container">
  90. <WithView v-model="imageUrl" :limit="1" :assetName="'周转车'"/>
  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 { getAssetInfo , saveOrEdit } from '@/api/ledgerAssets';
  147. import { listOrganizations } from '@/api/system/organization';
  148. import WithView from '@/components/upload/WithView';
  149. import dictMixins from '@/mixins/dictMixins';
  150. export default {
  151. mixins: [dictMixins],
  152. components: {
  153. WithView
  154. },
  155. data () {
  156. return {
  157. formData: {},
  158. info: {
  159. category: {},
  160. warehouseDetail: {},
  161. },
  162. customRule: {},
  163. itemForm: {
  164. addList: []
  165. },
  166. imageUrl: {},
  167. treeData:[],
  168. btnLoading: false,
  169. };
  170. },
  171. created () {
  172. let id = this.$route.query.id;
  173. this.getDetilInfo(id);
  174. this.query();
  175. this.requestDict('周转车材质');
  176. },
  177. methods: {
  178. // 树形结构数据
  179. query() {
  180. listOrganizations()
  181. .then((list) => {
  182. this.treeData = this.$util.toTreeData({
  183. data: list,
  184. idField: 'id',
  185. parentIdField: 'parentId'
  186. });
  187. })
  188. .catch((e) => {
  189. });
  190. },
  191. async getDetilInfo (id) {
  192. const res = await getAssetInfo(id);
  193. if (res) {
  194. this.info = res;
  195. this.$set(this.info, 'category', res.category);
  196. this.itemForm.addList = this.info.extInfoSelf
  197. ? this.info.extInfoSelf
  198. : [];
  199. // 设备图片
  200. this.imageUrl = res.imageUrl?res.imageUrl:{}
  201. }
  202. },
  203. // 删除自定义参数
  204. delt (item, index) {
  205. this.itemForm.addList.splice(index, 1);
  206. },
  207. // 添加自定义参数
  208. addItem () {
  209. if (this.itemForm.addList.length < 10) {
  210. let item = { key: '', value: '' };
  211. this.itemForm.addList.push(item);
  212. } else {
  213. this.$message.warning('自定义参数最多添加10条');
  214. }
  215. },
  216. // 选择图片回调
  217. cbUploadImg (data) {
  218. if (data.length > 0) {
  219. this.imageUrl = data[0];
  220. } else {
  221. this.imageUrl = '';
  222. }
  223. },
  224. // 点击确定保存
  225. toSave () {
  226. let extendField = this.itemForm.addList;
  227. let params = {
  228. id: this.info.id,
  229. code: this.info.code,
  230. fixCode: this.info.fixCode,
  231. imageUrl: this.imageUrl || {},
  232. extInfoSelf: extendField,
  233. ownershipGroupId: this.info.ownershipGroupId,
  234. rootCategoryLevelId:this.info.rootCategoryLevelId,
  235. categoryId:this.info.categoryId,
  236. positionIds: typeof this.info.category.categoryLevelPathId == 'string'? this.info.category.categoryLevelPathId : JSON.parse(this.info.category.categoryLevelPathId).join(',')
  237. };
  238. this.btnLoading = true;
  239. this.$refs['formCustom'].validate((valid) => {
  240. if (valid) {
  241. saveOrEdit(params).then((res) => {
  242. if (res) {
  243. this.$message.success('周转车编辑成功');
  244. this.$router.go(-1);
  245. }
  246. })
  247. .finally(() => {
  248. this.btnLoading = false;
  249. });
  250. } else {
  251. return false;
  252. }
  253. });
  254. }
  255. // //使用说明书
  256. // operatingManual (info) {
  257. // if (info.length > 0) {
  258. // console.log(info, '------info-----')
  259. // this.formData.operatingManual = info[0]
  260. // console.log(this.formData.operatingManual, 'getImgs')
  261. // } else {
  262. // this.formData.operatingManual = null
  263. // console.log(this.formData.operatingManual, 'getImgs')
  264. // }
  265. // },
  266. // productionLicence (info) {
  267. // this.formData.productionLicence = info[0]
  268. // },
  269. // explosionProofCertificate (info) {
  270. // this.formData.explosionProofCertificate = info[0]
  271. // },
  272. // surveyReport (info) {
  273. // this.formData.surveyReport = info[0]
  274. // },
  275. // inspectionCycleManual (info) {
  276. // this.formData.inspectionCycleManual = info[0]
  277. // },
  278. // informationDrawing (info) {
  279. // this.formData.informationDrawing = info[0]
  280. // },
  281. // productCertificate (info) {
  282. // this.formData.productCertificate = info[0]
  283. // }
  284. }
  285. };
  286. </script>
  287. <style lang="scss" scoped>
  288. .equipment-container {
  289. background-color: #fff;
  290. padding: 20px;
  291. .page-title{
  292. width:100%;
  293. padding-bottom: 10px;
  294. border-bottom:1px solid #ccc;
  295. }
  296. .basic-details-title {
  297. width: 100%;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. margin: 15px 0px;
  302. font-size: 16px;
  303. }
  304. .basic-details-title:first-child {
  305. margin: 0px 0px 15px;
  306. }
  307. .content {
  308. padding: 0 20px;
  309. }
  310. .label-none {
  311. .el-form-item__content {
  312. margin-left: 0 !important;
  313. }
  314. }
  315. .upload-container {
  316. display: flex;
  317. align-items: center;
  318. justify-content: center;
  319. // .file-list {
  320. // margin-left: 50px;
  321. // flex: 1;
  322. // }
  323. }
  324. .el-form-item__content {
  325. display: flex;
  326. }
  327. .row-form {
  328. width: 100%;
  329. .add-col {
  330. display: flex;
  331. align-items: center;
  332. margin-left: 20px;
  333. .col-input {
  334. margin-right: 5px;
  335. }
  336. }
  337. }
  338. .qsbm .el-select {
  339. width: 100%;
  340. }
  341. }
  342. </style>