certificateQualificationsDialog.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="certificateQualificationsDialogFlag"
  6. :title="title"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. width="80%"
  10. :before-close="cancel"
  11. >
  12. <el-form ref="form" :model="form">
  13. <headerTitle title="基本信息" />
  14. <el-row :gutter="20">
  15. <el-col :span="12">
  16. <el-form-item
  17. label-width="50px"
  18. label="名称"
  19. prop="name"
  20. :rules="{ required: true, message: '请输入', trigger: 'blur' }"
  21. >
  22. <el-input
  23. v-model="form.name"
  24. :disabled="type == 'view'"
  25. clearable
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="12">
  30. <el-form-item label-width="50px" label="备注">
  31. <el-input
  32. type="textarea"
  33. v-model="form.remark"
  34. :disabled="type == 'view'"
  35. clearable
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. <headerTitle title="资质信息" />
  41. <ele-pro-table
  42. ref="linkTable"
  43. :columns="columns"
  44. :datasource="form.detailsList"
  45. :toolkit="[]"
  46. height="300px"
  47. :need-page="false"
  48. >
  49. <!-- 表头工具栏 -->
  50. <template v-slot:toolbar>
  51. <el-button v-if="type !== 'view'" type="primary" @click="handleAdd"
  52. >添加</el-button
  53. >
  54. </template>
  55. <template v-slot:name="scope">
  56. <el-form-item
  57. :prop="'detailsList.' + scope.$index + '.name'"
  58. :rules="{
  59. required: true,
  60. message: '',
  61. trigger: 'change'
  62. }"
  63. >
  64. <el-select
  65. v-if="type !== 'view'"
  66. v-model="scope.row.name"
  67. clearable
  68. @change="(val) => handleChangeType(val, scope.row)"
  69. >
  70. <el-option
  71. :disabled="disabledToType(scope.row).includes(item.dictCode)"
  72. v-for="item in dictList"
  73. :value="item.dictValue"
  74. :label="item.dictValue"
  75. ></el-option>
  76. </el-select>
  77. <!-- <DictSelection v-if="type!=='view'" clearable dictName="客户/供应商资质类型" v-model="scope.row.type"-->
  78. <!-- @itemChange="(val)=>handleChangeType(val,scope.row)"></DictSelection>-->
  79. <span v-else>{{ scope.row.name }}</span>
  80. </el-form-item>
  81. </template>
  82. <template v-slot:code="scope">
  83. <el-form-item
  84. :prop="'detailsList.' + scope.$index + '.code'"
  85. >
  86. <el-input
  87. v-model="scope.row.code"
  88. :disabled="type == 'view'"
  89. clearable
  90. ></el-input>
  91. </el-form-item>
  92. </template>
  93. <template v-slot:businessRange="scope">
  94. <el-form-item
  95. :prop="'detailsList.' + scope.$index + '.businessRange'"
  96. >
  97. <el-input
  98. type="textarea"
  99. v-model="scope.row.businessRange"
  100. :disabled="type == 'view'"
  101. clearable
  102. ></el-input>
  103. </el-form-item>
  104. </template>
  105. <template v-slot:startTime="scope">
  106. <el-form-item
  107. inline-message
  108. :prop="'detailsList.' + scope.$index + '.startTime'"
  109. :rules="{
  110. required: false,
  111. message: '',
  112. trigger: 'change'
  113. }"
  114. >
  115. <el-date-picker
  116. :disabled="type == 'view'"
  117. v-model="scope.row.startTime"
  118. type="date"
  119. style="width: 100%"
  120. value-format="yyyy-MM-dd"
  121. placeholder="选择日期"
  122. >
  123. </el-date-picker>
  124. </el-form-item>
  125. </template>
  126. <template v-slot:endTime="scope">
  127. <el-form-item
  128. :prop="'detailsList.' + scope.$index + '.endTime'"
  129. :rules="{
  130. required: false,
  131. validator: validateEndDate(scope.row, scope.$index),
  132. trigger: ['blur', 'change']
  133. }"
  134. >
  135. <el-date-picker
  136. :disabled="type == 'view'"
  137. v-model="scope.row.endTime"
  138. type="date"
  139. style="width: 100%"
  140. value-format="yyyy-MM-dd"
  141. placeholder="选择日期"
  142. >
  143. </el-date-picker>
  144. </el-form-item>
  145. </template>
  146. <template v-slot:noticePersonName="scope">
  147. <el-form-item
  148. :prop="'detailsList.' + scope.$index + '.noticePersonName'"
  149. >
  150. <el-input
  151. :disabled="type == 'view'"
  152. @click.native="openStaffSelection(scope.$index)"
  153. v-model="scope.row.noticePersonName"
  154. placeholder="请选择"
  155. ></el-input>
  156. </el-form-item>
  157. </template>
  158. <template v-slot:accessory="scope">
  159. <el-form-item
  160. :prop="'detailsList.' + scope.$index + '.accessory'"
  161. :rules="{
  162. required: true,
  163. message: '',
  164. trigger: ['change', 'blur']
  165. }"
  166. >
  167. <fileMain v-model="scope.row.accessory" :type="type"></fileMain>
  168. <!-- <fileUpload-->
  169. <!-- v-if="type!=='view'"-->
  170. <!-- v-model="scope.row.accessory"-->
  171. <!-- module="main"-->
  172. <!-- :showLib="false"-->
  173. <!-- :limit="10"/>-->
  174. <!-- <div v-else>-->
  175. <!-- <el-link-->
  176. <!-- v-for="link in scope.row.accessory"-->
  177. <!-- :key="link.id"-->
  178. <!-- type="primary"-->
  179. <!-- :underline="false"-->
  180. <!-- @click="downloadFile(link)">-->
  181. <!-- {{ link.name }}-->
  182. <!-- </el-link>-->
  183. <!-- </div>-->
  184. </el-form-item>
  185. </template>
  186. <template v-slot:type="scope">
  187. <el-form-item :prop="'detailsList.' + scope.$index + '.type'">
  188. <el-select
  189. v-if="type !== 'view'"
  190. v-model="scope.row.type"
  191. clearable
  192. >
  193. <el-option
  194. v-for="item in typeList"
  195. :value="item.dictCode"
  196. :label="item.dictValue"
  197. ></el-option>
  198. </el-select>
  199. <span v-else>{{ getLabelName(typeList, scope.row.type) }}</span>
  200. </el-form-item>
  201. </template>
  202. <template v-slot:level="scope">
  203. <el-form-item :prop="'detailsList.' + scope.$index + '.level'">
  204. <el-select
  205. v-if="type !== 'view'"
  206. v-model="scope.row.level"
  207. clearable
  208. >
  209. <el-option
  210. v-for="item in levelOptions"
  211. :value="item.dictCode"
  212. :label="item.dictValue"
  213. ></el-option>
  214. </el-select>
  215. <span v-else>{{ getLabelName(levelOptions, scope.row.type) }}</span>
  216. </el-form-item>
  217. </template>
  218. <template v-slot:remark="scope">
  219. <el-form-item :prop="'detailsList.' + scope.$index + '.remark'">
  220. <el-input
  221. type="textarea"
  222. :disabled="type == 'view'"
  223. v-model="scope.row.remark"
  224. ></el-input>
  225. </el-form-item>
  226. </template>
  227. <template v-slot:status="scope">
  228. <el-form-item :prop="'detailsList.' + scope.$index + '.status'">
  229. <el-tag
  230. v-if="scope.row.status"
  231. :type="statusTagTypeList[scope.row.status]"
  232. >
  233. {{ statusList[scope.row.status] }}
  234. </el-tag>
  235. </el-form-item>
  236. </template>
  237. <template v-slot:isRequired="{ column }">
  238. <span class="is-required">{{ column.label }}</span>
  239. </template>
  240. <template v-slot:action="{ row, $index }">
  241. <el-popconfirm
  242. class="ele-action"
  243. title="确定要删除该信息吗?"
  244. @confirm="handleRemove($index)"
  245. >
  246. <template v-slot:reference>
  247. <el-link
  248. v-if="type !== 'view'"
  249. type="danger"
  250. :underline="false"
  251. icon="el-icon-delete"
  252. >
  253. 删除
  254. </el-link>
  255. </template>
  256. </el-popconfirm>
  257. </template>
  258. </ele-pro-table>
  259. </el-form>
  260. <div slot="footer">
  261. <el-button
  262. type="primary"
  263. v-if="type !== 'view'"
  264. @click="handleSave(false)"
  265. >保存</el-button
  266. >
  267. <!-- <el-button type="primary" v-if="type!=='view'" plan @click="handleSave(true)">提交</el-button>-->
  268. <el-button @click="cancel">返回</el-button>
  269. </div>
  270. <staffSelection
  271. ref="staffSelection"
  272. @confirm="confirmStaffSelection"
  273. ></staffSelection>
  274. </ele-modal>
  275. </template>
  276. <script>
  277. import FileUpload from '@/components/upload/fileUpload.vue';
  278. import staffSelection from '@/components/staffSelection/staffSelection.vue';
  279. import {
  280. contactQcPackDetailAPI,
  281. contactQcPackSaveAPI,
  282. contactQcPackUpdateAPI,
  283. contactQcSubmit
  284. } from '@/api/bpm/components/supplierManage/contact';
  285. import { getFile } from '@/api/system/file';
  286. import { mapActions, mapGetters } from 'vuex';
  287. import dictEnum from '@/enum/dict';
  288. import fileMain from '@/components/addDoc/index.vue';
  289. export default {
  290. name: 'certificateQualificationsDialog',
  291. components: { fileMain, FileUpload, staffSelection },
  292. props: {
  293. certificateQualificationsDialogFlag: Boolean,
  294. contactId: String,
  295. typeInfo: String
  296. },
  297. computed: {
  298. ...mapGetters(['dict']),
  299. dictList() {
  300. return this.dict[dictEnum['客户/供应商资质类型']] || [];
  301. },
  302. typeList() {
  303. return this.dict[dictEnum['工种类型']] || [];
  304. },
  305. columns() {
  306. return [
  307. {
  308. type: 'index',
  309. width: 55,
  310. align: 'center'
  311. },
  312. {
  313. label: '名称',
  314. prop: 'name',
  315. slot: 'name',
  316. headerSlot: 'isRequired',
  317. minWidth: 180,
  318. align: 'center'
  319. },
  320. {
  321. label: '编号',
  322. prop: 'code',
  323. slot: 'code',
  324. // headerSlot: 'isRequired',
  325. minWidth: 120,
  326. align: 'center'
  327. },
  328. {
  329. label: '许可/经营范围',
  330. prop: 'businessRange',
  331. slot: 'businessRange',
  332. minWidth: 140,
  333. align: 'center'
  334. },
  335. {
  336. label: '有效期起始日期',
  337. prop: 'startTime',
  338. slot: 'startTime',
  339. // headerSlot: 'isRequired',
  340. minWidth: 160,
  341. align: 'center'
  342. },
  343. {
  344. label: '有效期截止日期',
  345. prop: 'endTime',
  346. slot: 'endTime',
  347. // headerSlot: 'isRequired',
  348. minWidth: 160,
  349. align: 'center'
  350. },
  351. {
  352. label: '通知人',
  353. prop: 'noticePersonName',
  354. slot: 'noticePersonName',
  355. // headerSlot: 'isRequired',
  356. minWidth: 140,
  357. align: 'center'
  358. },
  359. {
  360. label: '附件',
  361. prop: 'accessory',
  362. slot: 'accessory',
  363. headerSlot: 'isRequired',
  364. minWidth: 140
  365. },
  366. {
  367. label: '等级',
  368. prop: 'level',
  369. slot: 'level',
  370. minWidth: 140,
  371. align: 'center'
  372. },
  373. {
  374. label: '分类',
  375. prop: 'type',
  376. slot: 'type',
  377. minWidth: 140,
  378. align: 'center'
  379. },
  380. {
  381. label: '备注',
  382. prop: 'remark',
  383. slot: 'remark',
  384. minWidth: 140,
  385. align: 'center'
  386. },
  387. {
  388. label: '状态',
  389. prop: 'status',
  390. slot: 'status',
  391. align: 'center'
  392. },
  393. {
  394. action: 'action',
  395. slot: 'action',
  396. label: '操作',
  397. align: 'center',
  398. fixed: 'right'
  399. }
  400. ];
  401. },
  402. disabledToType() {
  403. return (row) => {
  404. let list = this.form.detailsList.map((item) => item.type);
  405. let dictCodeList = this.dictList.map((item) => item.dictCode);
  406. let intersectionList = list.filter(
  407. (v) => dictCodeList.indexOf(v) > -1
  408. );
  409. intersectionList = intersectionList.filter((v) => row.type !== v);
  410. return intersectionList;
  411. };
  412. }
  413. },
  414. created() {
  415. this.requestDict('客户/供应商资质类型');
  416. },
  417. data() {
  418. return {
  419. title: '',
  420. type: '',
  421. defaultData: {
  422. files: [],
  423. name: '',
  424. notifyUserId: '',
  425. notifyUserName: '',
  426. num: '',
  427. remark: '',
  428. scope: '',
  429. type: '',
  430. validityPeriodEnd: '',
  431. validityPeriodStart: ''
  432. },
  433. form: {
  434. detailsList: [],
  435. contactId: '',
  436. name: '',
  437. remark: ''
  438. },
  439. curIndex: null,
  440. statusList: {
  441. 10: '有效',
  442. 20: '无效',
  443. 30: '已过期'
  444. },
  445. statusTagTypeList: {
  446. 10: 'success',
  447. 20: 'info',
  448. 30: 'danger'
  449. },
  450. levelOptions: [
  451. {
  452. dictValue: '初级',
  453. dictCode: '1'
  454. },
  455. {
  456. dictValue: '中级',
  457. dictCode: '2'
  458. },
  459. {
  460. dictValue: '高级',
  461. dictCode: '3'
  462. }
  463. ],
  464. };
  465. },
  466. methods: {
  467. ...mapActions('dict', ['requestDict']),
  468. getLabelName(arr, id) {
  469. if (!id) return '';
  470. return arr.find((item) => item.dictCode == id)?.dictValue;
  471. },
  472. //结束日期验证
  473. validateEndDate(row, index) {
  474. return (rule, value, callback) => {
  475. if (!value) return callback(new Error(''));
  476. if (
  477. row.validityPeriodEnd &&
  478. row.validityPeriodStart &&
  479. value < row.validityPeriodStart
  480. ) {
  481. callback(new Error('截止日期不能小于起始日期'));
  482. } else {
  483. callback();
  484. }
  485. };
  486. },
  487. //页面初始化
  488. init(type, row = {}) {
  489. this.title =
  490. type == 'add' ? '新增' : type == 'update' ? '修改' : '详情';
  491. this.type = type;
  492. if (type !== 'add') {
  493. this.getCertificateInfo(row);
  494. }
  495. },
  496. async getCertificateInfo(row) {
  497. this.form = await contactQcPackDetailAPI(row.id);
  498. },
  499. //打开选择负责人弹窗
  500. openStaffSelection(index) {
  501. this.curIndex = index;
  502. this.$refs.staffSelection.open([]);
  503. },
  504. //选择负责人回调
  505. confirmStaffSelection(data) {
  506. this.form.detailsList[this.curIndex].notifyUserName = data
  507. .map((item) => item.name)
  508. .toString();
  509. this.form.detailsList[this.curIndex].notifyUserId = data
  510. .map((item) => item.id)
  511. .toString();
  512. },
  513. //删除资质
  514. handleRemove(index) {
  515. this.form.detailsList.splice(index, 1);
  516. },
  517. //新增
  518. handleAdd() {
  519. this.form.detailsList.push({ ...this.defaultData });
  520. },
  521. //修改资质证书
  522. handleChangeType(val, row) {
  523. if (!val) return (row.name = '');
  524. row.name =
  525. this.dictList.find((i) => i.dictCode == val)?.dictValue || '';
  526. },
  527. downloadFile(file) {
  528. getFile({ objectName: file.storePath }, file.name);
  529. },
  530. //保存/提交
  531. handleSave(isSub) {
  532. if (!this.contactId)
  533. return this.$message.success('请保存合同信息后新增资质');
  534. this.$refs.form.validate(async (valid) => {
  535. if (!valid) return this.$message.warning('有必填项未填写,请检查');
  536. if (!this.form.detailsList.length)
  537. return this.$message.warning('至少保存一条资质信息');
  538. this.form.contactId = this.contactId;
  539. let api =
  540. this.type == 'add' ? contactQcPackSaveAPI : contactQcPackUpdateAPI;
  541. let id = await api(this.form);
  542. if (isSub) {
  543. await contactQcSubmit({ businessId: id, type: this.typeInfo });
  544. }
  545. this.$message.success('保存成功');
  546. this.$emit('reload');
  547. this.cancel();
  548. });
  549. },
  550. //关闭弹窗
  551. cancel() {
  552. this.$emit('update:certificateQualificationsDialogFlag', false);
  553. }
  554. }
  555. };
  556. </script>
  557. <style scoped lang="scss">
  558. :deep.el-form-item {
  559. margin-bottom: 0;
  560. }
  561. </style>