edit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <div>
  3. <headerTitle title="基本信息" style="margin-top: 15px"></headerTitle>
  4. <el-form
  5. ref="form"
  6. :model="form"
  7. :rules="rules"
  8. label-width="100px"
  9. class="create-form"
  10. >
  11. <el-row :gutter="15">
  12. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  13. <el-form-item label="编码:" prop="code">
  14. <el-input v-model="form.code" disabled />
  15. </el-form-item>
  16. </el-col>
  17. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  18. <el-form-item
  19. label="工单编码:"
  20. prop="repairCode"
  21. v-if="type != 'edit'"
  22. >
  23. <el-input v-model="form.repairCode" disabled />
  24. </el-form-item>
  25. <el-form-item label="工单编码:" prop="repairCode" v-else>
  26. <el-input
  27. v-model="form.repairCode"
  28. @click.native="addRepair"
  29. placeholder="请选择工单"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  34. <el-form-item label="工单名称:" prop="repairName">
  35. <el-input v-model="form.repairName" 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="receivingDeptName">
  40. <el-input v-model="form.receivingDeptName" disabled />
  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="recipientName">
  45. <el-input v-model="form.recipientName" disabled />
  46. </el-form-item>
  47. </el-col>
  48. <el-col v-bind="styleResponsive ? { lg: 8, md: 12 } : { span: 8 }">
  49. <el-form-item label="使用时间:" prop="usageTime">
  50. <el-date-picker
  51. style="width: 100%"
  52. v-model="form.usageTime"
  53. type="date"
  54. placeholder="选择"
  55. :disabled="type == 'detail'"
  56. value-format="yyyy-MM-dd"
  57. >
  58. </el-date-picker>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="8">
  62. <el-form-item label="使用部门" prop="useDeptName">
  63. <el-input v-model="form.useDeptName" :disabled="type == 'detail'" />
  64. <!-- <deptSelect
  65. :disabled="type == 'detail'"
  66. v-model="form.useDeptId"
  67. @changeGroup="searchDeptNodeClick"
  68. /> -->
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="8">
  72. <el-form-item label="使用人" prop="userName">
  73. <el-input v-model="form.userName" :disabled="type == 'detail'" />
  74. <!-- <el-select
  75. :disabled="type == 'detail'"
  76. v-model="form.userId"
  77. @change="changeExecutor"
  78. size="small"
  79. style="width: 100%"
  80. filterable
  81. >
  82. <el-option
  83. v-for="item in executorList"
  84. :key="item.id"
  85. :value="item.id"
  86. :label="item.name"
  87. ></el-option>
  88. </el-select> -->
  89. </el-form-item>
  90. </el-col>
  91. <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 16 }">
  92. <el-form-item label="用途:" prop="purpose">
  93. <el-input
  94. v-model="form.purpose"
  95. type="textarea"
  96. :rows="2"
  97. :disabled="type == 'detail'"
  98. />
  99. </el-form-item>
  100. </el-col> </el-row
  101. ></el-form>
  102. <headerTitle title="设备信息" style="margin-top: 15px"></headerTitle>
  103. <ele-pro-table
  104. ref="table"
  105. :columns="deviceColumns"
  106. :datasource="deviceList"
  107. row-key="id"
  108. height="20vh"
  109. :needPage="false"
  110. >
  111. <template v-slot:toolbar>
  112. <div
  113. class="add-product"
  114. @click="materialAdd"
  115. v-if="type != 'detail' && !form.repairCode"
  116. >
  117. <i class="el-icon-circle-plus-outline"></i>
  118. </div>
  119. </template>
  120. <template v-slot:modelType="{ row }">
  121. <span>{{ (row.category && row.category.modelType) || row.model }}</span>
  122. </template>
  123. <!-- <template v-slot:specification="{ row }">
  124. <span>{{ row.category.specification }}</span>
  125. </template> -->
  126. <template v-slot:action="{ row }">
  127. <el-popconfirm
  128. v-if="type != 'detail'"
  129. class="ele-action"
  130. title="确定要删除吗?"
  131. @confirm="del(row.id, 1)"
  132. >
  133. <template v-slot:reference>
  134. <el-link type="danger" :underline="false" icon="el-icon-delete">
  135. 删除
  136. </el-link>
  137. </template>
  138. </el-popconfirm>
  139. </template>
  140. </ele-pro-table>
  141. <headerTitle title="备品备件信息" style="margin-top: 15px"></headerTitle>
  142. <ele-pro-table
  143. ref="table"
  144. :columns="columns"
  145. :datasource="tableList"
  146. row-key="id"
  147. height="20vh"
  148. :needPage="false"
  149. >
  150. <template v-slot:toolbar>
  151. <div class="add-product" @click="addEquipment" v-if="type != 'detail'">
  152. <i class="el-icon-circle-plus-outline"></i>
  153. </div>
  154. </template>
  155. <template v-slot:totalCount="{ row, $index }" v-if="type != 'detail'">
  156. <el-input
  157. type="number"
  158. placeholder="请输入"
  159. v-model="row.totalCount"
  160. @input="handleInput(row, $index)"
  161. />
  162. </template>
  163. <template v-slot:action="{ row }">
  164. <el-popconfirm
  165. v-if="type != 'detail'"
  166. class="ele-action"
  167. title="确定要删除吗?"
  168. @confirm="del(row.id)"
  169. >
  170. <template v-slot:reference>
  171. <el-link type="danger" :underline="false" icon="el-icon-delete">
  172. 删除
  173. </el-link>
  174. </template>
  175. </el-popconfirm>
  176. </template>
  177. </ele-pro-table>
  178. <!-- 选择产品 -->
  179. <AssetsDialog ref="equipmentRefs" :assetType="6" @choose="confirmChoose">
  180. </AssetsDialog>
  181. <!-- <MaterialAdd ref="materialAddRef" @chooseEquipment="chooseEquipment">
  182. </MaterialAdd> -->
  183. <workList ref="workListRef" @open="init"> </workList>
  184. </div>
  185. </template>
  186. <script>
  187. import AssetsDialog from './AssetsDialog.vue';
  188. import workList from './workList.vue';
  189. // import MaterialAdd from '@/views/maintenance/components/MaterialAdd.vue';
  190. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  191. import { getUserPage } from '@/api/system/organization';
  192. import { detailsId } from '@/api/bpm/components/sparePartsApply/index.js';
  193. const defForm = {
  194. name: '',
  195. repairId: '', //维修工单id
  196. repairCode: '',
  197. code: '',
  198. repairName: '',
  199. deviceName: '',
  200. fixCode: '',
  201. deviceCode: '',
  202. type: '4', //类型
  203. status: '1', //状态
  204. purpose: '',
  205. userId: '', //使用人id
  206. userName: '',
  207. useDeptId: '', //使用部门
  208. useDeptName: '',
  209. warehouseId: '',
  210. recipientId: 0, //领用人id
  211. recipientName: '', //领用人名称
  212. receivingDeptId: 0, //领用部门id
  213. receivingDeptName: '', //领用部门id
  214. usageTime: '', //使用时间 //详情信息
  215. detailList: [],
  216. deviceList: []
  217. };
  218. export default {
  219. components: {
  220. AssetsDialog,
  221. // MaterialAdd,
  222. workList,
  223. deptSelect
  224. },
  225. props: {
  226. businessId: {
  227. default: ''
  228. },
  229. taskDefinitionKey: {
  230. default: ''
  231. }
  232. },
  233. data() {
  234. return {
  235. loading: false,
  236. type: '',
  237. executorList: [],
  238. form: { ...defForm },
  239. rules: {
  240. deviceName: [{ required: true, message: '请选择', trigger: 'change' }],
  241. useDeptName: [{ required: true, message: '请输入', trigger: 'change' }],
  242. userName: [{ required: true, message: '请输入', trigger: 'change' }],
  243. },
  244. sparePartsApplyList: [],
  245. tableList: [],
  246. deviceList: [],
  247. columns: [],
  248. deviceColumns: [
  249. {
  250. columnKey: 'index',
  251. label: '序号',
  252. type: 'index',
  253. width: 55,
  254. align: 'center',
  255. showOverflowTooltip: true,
  256. fixed: 'left'
  257. },
  258. {
  259. prop: 'fixCode',
  260. label: '固资编码',
  261. showOverflowTooltip: true,
  262. align: 'center'
  263. },
  264. {
  265. prop: 'codeNumber',
  266. label: '编码',
  267. showOverflowTooltip: true,
  268. align: 'center'
  269. },
  270. {
  271. prop: 'name',
  272. showOverflowTooltip: true,
  273. label: '名称',
  274. align: 'center'
  275. },
  276. {
  277. prop: 'modelType',
  278. showOverflowTooltip: true,
  279. label: '型号',
  280. slot: 'modelType',
  281. align: 'center'
  282. },
  283. // {
  284. // prop: 'specification',
  285. // showOverflowTooltip: true,
  286. // label: '规格',
  287. // slot: 'action',
  288. // align: 'specification'
  289. // },
  290. // {
  291. // showOverflowTooltip: true,
  292. // prop: 'postName',
  293. // label: '使用部门',
  294. // align: 'center'
  295. // },
  296. // {
  297. // prop: 'usePerson',
  298. // showOverflowTooltip: true,
  299. // label: '使用人',
  300. // align: 'center'
  301. // },
  302. {
  303. columnKey: 'action',
  304. label: '操作',
  305. width: 140,
  306. align: 'center',
  307. resizable: false,
  308. fixed: 'right',
  309. slot: 'action',
  310. showOverflowTooltip: true
  311. }
  312. ]
  313. };
  314. },
  315. computed: {
  316. // 是否开启响应式布局
  317. styleResponsive() {
  318. return this.$store.state.theme.styleResponsive;
  319. }
  320. },
  321. created() {
  322. this.type = this.taskDefinitionKey == 'fqr' ? 'edit' : 'detail';
  323. this.open();
  324. },
  325. methods: {
  326. addRepair() {
  327. this.$refs.workListRef.open();
  328. },
  329. materialAdd() {
  330. this.$refs.materialAddRef.open(null, null, true, this.deviceList);
  331. },
  332. // 确定选择
  333. chooseEquipment(data) {
  334. this.deviceList.push(...data);
  335. },
  336. // 出库数量限制
  337. handleInput(row, index) {
  338. if (row.totalCount > row.measureQuantity) {
  339. this.$set(this.tableList[index], 'totalCount', row.measureQuantity);
  340. }
  341. },
  342. async open() {
  343. this.columns = [
  344. {
  345. columnKey: 'index',
  346. label: '序号',
  347. type: 'index',
  348. width: 55,
  349. align: 'center',
  350. showOverflowTooltip: true,
  351. fixed: 'left'
  352. },
  353. {
  354. prop: 'categoryCode',
  355. label: '物品编码',
  356. align: 'center'
  357. },
  358. {
  359. prop: 'categoryName',
  360. label: '物品名称',
  361. align: 'center'
  362. },
  363. {
  364. prop: 'categoryModel',
  365. label: '型号',
  366. align: 'center'
  367. },
  368. {
  369. prop: 'specification',
  370. label: '规格',
  371. align: 'center'
  372. },
  373. {
  374. prop: 'level',
  375. label: '级别',
  376. align: 'center'
  377. },
  378. {
  379. prop: 'totalCount',
  380. label: '数量',
  381. align: 'center',
  382. slot: 'totalCount'
  383. },
  384. {
  385. prop: 'measureQuantity',
  386. label: '库存',
  387. align: 'center',
  388. show: this.type != 'detail'
  389. },
  390. {
  391. prop: 'measureUnit',
  392. label: '计量单位',
  393. align: 'center'
  394. },
  395. {
  396. prop: 'warehouseName',
  397. label: '仓库',
  398. align: 'center'
  399. },
  400. {
  401. columnKey: 'action',
  402. label: '操作',
  403. width: 140,
  404. align: 'center',
  405. resizable: false,
  406. fixed: 'right',
  407. slot: 'action',
  408. showOverflowTooltip: true
  409. }
  410. ];
  411. const data = await detailsId(this.businessId);
  412. this.form = data;
  413. if (this.form.useDeptId) {
  414. this.getUserList({ groupId: this.form.useDeptId });
  415. }
  416. this.tableList = data.detailList;
  417. this.deviceList = data.deviceList;
  418. },
  419. del(id, type) {
  420. if (type == 1) {
  421. this.deviceList = this.deviceList.filter((item) => item.id != id);
  422. return;
  423. }
  424. this.tableList = this.tableList.filter((item) => item.id != id);
  425. },
  426. addEquipment() {
  427. this.$refs.equipmentRefs.open(this.tableList);
  428. },
  429. /* 保存编辑 */
  430. async getTableValue() {
  431. if (this.deviceList.length == 0) {
  432. this.$message.error('请选择设备!');
  433. return;
  434. }
  435. if (this.tableList.length == 0) {
  436. this.$message.error('请选择备品备件!');
  437. return;
  438. }
  439. let boolen = this.tableList.every((item) => item.totalCount > 0);
  440. if (!boolen) {
  441. this.$message.error('请输入出库数量!');
  442. return;
  443. }
  444. this.form.detailList = this.tableList;
  445. this.form.deviceList = this.deviceList;
  446. return this.form
  447. // save(this.form)
  448. // .then((res) => {
  449. // this.loading = false;
  450. // this.$message.success('成功');
  451. // this.cancel();
  452. // this.$emit('refresh');
  453. // })
  454. // .catch((e) => {
  455. // this.loading = false;
  456. // });
  457. },
  458. init(row) {
  459. if (!row) {
  460. return;
  461. }
  462. this.form.repairCode = row.code;
  463. this.form.repairName = row.planName;
  464. this.form.repairId = row.id;
  465. this.deviceList = row.deviceList;
  466. },
  467. // 确定选择
  468. confirmChoose(data) {
  469. this.tableList = JSON.parse(JSON.stringify(data));
  470. },
  471. //选择部门(搜索)
  472. searchDeptNodeClick(info, row) {
  473. if (info) {
  474. const params = { groupId: info };
  475. this.getUserList(params);
  476. this.form.useDeptName = row.name;
  477. } else {
  478. this.form.executeGroupId = null;
  479. }
  480. },
  481. // 人员
  482. async getUserList(params) {
  483. try {
  484. let data = { pageNum: 1, size: -1 };
  485. // 如果传了参数就是获取巡点检人员数据
  486. if (params) {
  487. data = Object.assign(data, params);
  488. }
  489. const res = await getUserPage(data);
  490. this.executorList = res.list;
  491. } catch (error) {}
  492. },
  493. // 人员选择
  494. changeExecutor(val) {
  495. if (val) {
  496. this.form.userId = val;
  497. this.form.userName = this.executorList.filter(
  498. (item) => item.id === val
  499. )[0].name;
  500. }
  501. }
  502. }
  503. };
  504. </script>
  505. <style lang="scss" scoped>
  506. .basic-details-title {
  507. margin: 10px 0;
  508. }
  509. .title {
  510. font-size: 16px;
  511. line-height: 45px;
  512. }
  513. .add-product {
  514. width: 100%;
  515. display: flex;
  516. align-items: center;
  517. // justify-content: flex-end;
  518. font-size: 30px;
  519. color: #1890ff;
  520. margin: 10px 0;
  521. cursor: pointer;
  522. }
  523. </style>