edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. :title="title"
  5. width="60vw"
  6. append-to-body
  7. @close="cancel"
  8. >
  9. <div class="switch" v-if="type == 'detail'">
  10. <div class="switch_left">
  11. <ul>
  12. <li
  13. v-for="item in tabOptions"
  14. :key="item.key"
  15. :class="{ active: activeComp == item.key }"
  16. @click="activeComp = item.key"
  17. >
  18. {{ item.name }}
  19. </li>
  20. </ul>
  21. </div>
  22. </div>
  23. <el-form
  24. ref="form"
  25. :model="form"
  26. :rules="rules"
  27. label-width="100px"
  28. class="create-form"
  29. v-if="activeComp === 'main'"
  30. >
  31. <headerTitle title="基本信息" style="margin-top: 15px"></headerTitle>
  32. <el-row :gutter="15">
  33. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  34. <el-form-item label="编码:" prop="code">
  35. <el-input v-model="form.code" disabled />
  36. </el-form-item>
  37. </el-col>
  38. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  39. <el-form-item label="名称:" prop="name">
  40. <el-input v-model="form.name" :disabled="type == 'detail'" />
  41. </el-form-item>
  42. </el-col>
  43. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  44. <el-form-item label="用途类型:" prop="managementCategory">
  45. <DictSelection
  46. dictName="管理类别"
  47. v-model="form.managementCategory"
  48. :disabled="type == 'detail'"
  49. ></DictSelection>
  50. </el-form-item>
  51. </el-col>
  52. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  53. <el-form-item label="申请机构:" prop="managementCategory">
  54. <deptSelect
  55. :disabled="type == 'detail'"
  56. v-model="form.useDeptId"
  57. @changeGroup="searchDeptNodeClick"
  58. />
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="8">
  62. <el-form-item label="申请人" prop="userId">
  63. <el-select
  64. :disabled="type == 'detail'"
  65. v-model="form.userId"
  66. @change="changeExecutor"
  67. size="small"
  68. style="width: 100%"
  69. filterable
  70. >
  71. <el-option
  72. v-for="item in executorList"
  73. :key="item.id"
  74. :value="item.id"
  75. :label="item.name"
  76. ></el-option>
  77. </el-select>
  78. </el-form-item>
  79. </el-col>
  80. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  81. <el-form-item label="审批流程:" prop="processId">
  82. <el-select
  83. filterable
  84. clear
  85. size="small"
  86. v-model="form.processId"
  87. :disabled="type == 'detail'"
  88. placeholder="请选择"
  89. style="width: 100%"
  90. >
  91. <el-option
  92. :key="item.id"
  93. :value="item.id"
  94. :label="item.name"
  95. v-for="item in bpmList"
  96. ></el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. </el-row>
  101. <headerTitle title="租赁明细" style="margin-top: 15px"></headerTitle>
  102. <ele-pro-table
  103. ref="table"
  104. :columns="columns"
  105. :datasource="deviceList"
  106. row-key="id"
  107. height="30vh"
  108. :needPage="false"
  109. >
  110. <template v-slot:toolbar>
  111. <div
  112. class="add-product"
  113. @click="addEquipment"
  114. v-if="type != 'detail'"
  115. >
  116. <i class="el-icon-circle-plus-outline"></i>
  117. </div>
  118. </template>
  119. <template v-slot:modelType="{ row }">
  120. <span>{{ row.category.modelType }}</span>
  121. </template>
  122. <template v-slot:specification="{ row }">
  123. <span>{{ row.category.specification }}</span>
  124. </template>
  125. <template v-slot:action="{ row }">
  126. <el-popconfirm
  127. v-if="type != 'detail'"
  128. class="ele-action"
  129. title="确定要删除吗?"
  130. @confirm="del(row.id)"
  131. >
  132. <template v-slot:reference>
  133. <el-link type="danger" :underline="false" icon="el-icon-delete">
  134. 删除
  135. </el-link>
  136. </template>
  137. </el-popconfirm>
  138. </template>
  139. </ele-pro-table>
  140. </el-form>
  141. <template v-slot:footer>
  142. <el-button @click="cancel">取消</el-button>
  143. <el-button
  144. type="primary"
  145. @click="save"
  146. :loading="loading"
  147. v-if="type != 'detail'"
  148. >
  149. 保存
  150. </el-button>
  151. </template>
  152. <!-- 选择产品 -->
  153. <MaterialAdd ref="materialAddRef" @chooseEquipment="confirmChoose">
  154. </MaterialAdd>
  155. <Detail
  156. v-if="activeComp === 'bpm' && form.processInstanceId"
  157. :id="form.processInstanceId"
  158. ></Detail>
  159. </ele-modal>
  160. </template>
  161. <script>
  162. // import AssetsDialog from './AssetsDialog.vue';
  163. import MaterialAdd from '@/views/maintenance/components/MaterialAdd.vue';
  164. import Detail from '@/views/processInstance/detail.vue';
  165. import { getUserPage } from '@/api/system/organization';
  166. import { save,bpmPage } from '@/api/equipmentDisposal/index.js';
  167. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  168. const defForm = {
  169. name: '',
  170. id: '', //维修工单id
  171. disposalType: '',
  172. managementCategory: '',
  173. code: '',
  174. processId: '',
  175. disposalTypeList: [],
  176. deviceList: []
  177. };
  178. export default {
  179. components: {
  180. // AssetsDialog,
  181. MaterialAdd,
  182. deptSelect,
  183. Detail
  184. // workList
  185. },
  186. data() {
  187. return {
  188. activeComp: 'main',
  189. tabOptions: [
  190. { key: 'main', name: '处置详情' },
  191. { key: 'bpm', name: '流程详情' }
  192. ],
  193. visible: false,
  194. loading: false,
  195. isTemplate: false,
  196. infoDisposalVisible: false,
  197. title: '设备租赁',
  198. type: '',
  199. form: { ...defForm },
  200. rules: {
  201. name: [{ required: true, message: '请选择', trigger: 'change' }],
  202. type: [{ required: true, message: '请选择', trigger: 'change' }],
  203. processId: [{ required: true, message: '请选择', trigger: 'change' }],
  204. disposalType: [{ required: true, message: '请选择', trigger: 'change' }]
  205. },
  206. deviceList: [],
  207. disposalTypeList: [],
  208. columns: [],
  209. templateName: '',
  210. bpmList: [],
  211. executorList: []
  212. };
  213. },
  214. computed: {
  215. // 是否开启响应式布局
  216. styleResponsive() {
  217. return this.$store.state.theme.styleResponsive;
  218. }
  219. },
  220. async created() {
  221. const data = await bpmPage({
  222. pageSize: 100,
  223. pageNo: 1,
  224. processTypeId: '1853725791034118145'
  225. });
  226. this.bpmList = data.list;
  227. // console.log(this.bpmList)
  228. },
  229. methods: {
  230. async columnsInit(type) {
  231. this.columns = [
  232. {
  233. columnKey: 'index',
  234. label: '序号',
  235. type: 'index',
  236. width: 55,
  237. align: 'center',
  238. showOverflowTooltip: true,
  239. fixed: 'left'
  240. },
  241. {
  242. prop: 'fixCode',
  243. label: '固资编码',
  244. showOverflowTooltip: true,
  245. width: 100,
  246. fixed: 'left',
  247. align: 'center'
  248. },
  249. {
  250. prop: 'codeNumber',
  251. label: '编码',
  252. width: 100,
  253. fixed: 'left',
  254. showOverflowTooltip: true,
  255. align: 'center'
  256. },
  257. {
  258. prop: 'name',
  259. width: 120,
  260. fixed: 'left',
  261. showOverflowTooltip: true,
  262. label: '名称',
  263. align: 'center'
  264. },
  265. {
  266. prop: 'modelType',
  267. showOverflowTooltip: true,
  268. slot: 'modelType',
  269. label: '型号',
  270. align: 'center'
  271. },
  272. {
  273. prop: 'specification',
  274. showOverflowTooltip: true,
  275. slot: 'specification',
  276. label: '规格',
  277. align: 'center'
  278. },
  279. {
  280. prop: 'sealingTime',
  281. showOverflowTooltip: true,
  282. label: '封存时间',
  283. show: type == 6,
  284. align: 'center'
  285. },
  286. {
  287. showOverflowTooltip: true,
  288. prop: 'postName',
  289. label: '使用部门',
  290. align: 'center'
  291. },
  292. {
  293. prop: 'usePerson',
  294. showOverflowTooltip: true,
  295. label: '使用人',
  296. align: 'center'
  297. },
  298. {
  299. prop: 'serviceLife',
  300. label: '耐用年限',
  301. showOverflowTooltip: true,
  302. align: 'center'
  303. },
  304. {
  305. prop: 'alreadyServiceLife',
  306. label: '已使用年限',
  307. showOverflowTooltip: true,
  308. align: 'center'
  309. },
  310. {
  311. prop: 'originalValue',
  312. label: '原值',
  313. slot: 'originalValue',
  314. showOverflowTooltip: true,
  315. align: 'center'
  316. },
  317. {
  318. prop: 'netWorth',
  319. slot: 'netWorth',
  320. label: '净值',
  321. showOverflowTooltip: true,
  322. align: 'center'
  323. },
  324. {
  325. slot: 'scrapValue',
  326. prop: 'scrapValue',
  327. label: '残值',
  328. showOverflowTooltip: true,
  329. align: 'center'
  330. },
  331. {
  332. prop: 'manufacturer',
  333. label: '生产厂家',
  334. showOverflowTooltip: true,
  335. align: 'center'
  336. },
  337. {
  338. prop: 'pathName',
  339. label: '位置',
  340. showOverflowTooltip: true,
  341. minWidth: 110,
  342. formatter: (_row) => {
  343. const positionDetail =
  344. _row.position &&
  345. _row.position.length != 0 &&
  346. _row.position[0].detailPosition
  347. ? _row.position[0].detailPosition
  348. : '-';
  349. return _row.deviceLocationName
  350. ? _row.deviceLocationName + '-' + positionDetail
  351. : '';
  352. },
  353. align: 'center'
  354. },
  355. {
  356. columnKey: 'action',
  357. label: '操作',
  358. width: 140,
  359. align: 'center',
  360. resizable: false,
  361. fixed: 'right',
  362. slot: 'action',
  363. showOverflowTooltip: true
  364. }
  365. ];
  366. },
  367. async open(row, type) {
  368. this.activeComp = 'main';
  369. this.type = type;
  370. if (type != 'add') {
  371. this.form = JSON.parse(JSON.stringify(row));
  372. this.form.disposalType = this.form.disposalType + '';
  373. this.form.managementCategory = this.form.managementCategory + '';
  374. this.deviceList = this.form.deviceList;
  375. this.disposalTypeList = this.form.disposalTypeList;
  376. }
  377. this.columnsInit(this.form.disposalType);
  378. this.visible = true;
  379. },
  380. del(id) {
  381. this.deviceList = this.deviceList.filter((item) => item.id != id);
  382. },
  383. cancel() {
  384. this.form = { ...defForm };
  385. this.deviceList = [];
  386. this.disposalTypeList = [];
  387. console.log(this.deviceList, 'this.deviceList');
  388. this.visible = false;
  389. },
  390. addEquipment() {
  391. this.$refs.materialAddRef.open(null, null, true, this.deviceList);
  392. },
  393. // 确定选择
  394. confirmChoose(data) {
  395. this.deviceList.push(...data);
  396. },
  397. //选择部门(搜索)
  398. searchDeptNodeClick(info, row) {
  399. if (info) {
  400. const params = { groupId: info };
  401. this.getUserList(params);
  402. this.form.useDeptName = row.name;
  403. } else {
  404. this.form.executeGroupId = null;
  405. }
  406. },
  407. // 人员
  408. async getUserList(params) {
  409. try {
  410. let data = { pageNum: 1, size: -1 };
  411. // 如果传了参数就是获取巡点检人员数据
  412. if (params) {
  413. data = Object.assign(data, params);
  414. }
  415. const res = await getUserPage(data);
  416. this.executorList = res.list;
  417. } catch (error) {}
  418. },
  419. // 人员选择
  420. changeExecutor(val) {
  421. if (val) {
  422. this.form.userId = val;
  423. this.form.userName = this.executorList.filter(
  424. (item) => item.id === val
  425. )[0].name;
  426. }
  427. },
  428. /* 保存编辑 */
  429. async save() {
  430. if (this.deviceList.length == 0) {
  431. this.$message.error('请选择处置对象!');
  432. return;
  433. }
  434. this.form.deviceList = this.deviceList;
  435. this.form.disposalTypeList = this.disposalTypeList;
  436. this.$refs.form.validate(async (valid) => {
  437. if (valid) {
  438. this.loading = true;
  439. save(this.form)
  440. .then((res) => {
  441. this.loading = false;
  442. this.$message.success('成功');
  443. this.cancel();
  444. this.$emit('refresh');
  445. })
  446. .catch((e) => {
  447. this.loading = false;
  448. });
  449. }
  450. });
  451. }
  452. }
  453. };
  454. </script>
  455. <style lang="scss" scoped>
  456. .basic-details-title {
  457. margin: 10px 0;
  458. }
  459. .title {
  460. font-size: 16px;
  461. line-height: 45px;
  462. }
  463. .add-product {
  464. width: 100%;
  465. display: flex;
  466. align-items: center;
  467. // justify-content: flex-end;
  468. font-size: 30px;
  469. color: #1890ff;
  470. margin: 10px 0;
  471. cursor: pointer;
  472. }
  473. </style>