index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :columnParsing="columnParsing"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. :operation="operation()"
  11. >
  12. <div class="cartographer_big">
  13. <el-dialog title="配置" width="100%" :modal="false" :visible.sync="formBool" :before-close="handleClose">
  14. <zj-page-container v-if="formBool">
  15. <zj-page-fill class="neibuview">
  16. <zj-form-container
  17. ref="formRef"
  18. :form-data="formData"
  19. :form-rules="formRules"
  20. :form-attributes="{ size: 'mini' }"
  21. >
  22. <zj-form-module title="基础信息" label-width="110px" :form-data="formData" :form-items="items" />
  23. <zj-form-module
  24. v-if="formData.contractType == 'MAIN'"
  25. title="网点信息"
  26. :form-data="formData"
  27. :form-items="items2"
  28. />
  29. </zj-form-container>
  30. </zj-page-fill>
  31. <!-- 操作按钮 -->
  32. <div style="box-sizing: border-box; padding: 10px; text-align: right">
  33. <el-button size="mini" @click="handleClose">取 消</el-button>
  34. <el-button v-if="~[0, 1].indexOf(formType)" size="mini" @click="formConfirm" type="primary"
  35. >确 定</el-button
  36. >
  37. </div>
  38. </zj-page-container>
  39. </el-dialog>
  40. </div>
  41. </template-page>
  42. </template>
  43. <script>
  44. import TemplatePage from '@/components/template/template-page-1.vue'
  45. import import_mixin from '@/components/template/import_mixin.js'
  46. import pagingTransfer from '@/components/paging-transfer.vue'
  47. import {
  48. contractTemplateList,
  49. contractTemplateListExport,
  50. contractTemplateAdd,
  51. contractTemplateUpdate,
  52. contractTemplateDetail,
  53. contractTemplateQueryRelaWebsit,
  54. contractTemplateDel,
  55. contractTemplateStatus
  56. } from '@/api/fddContractTemplate'
  57. import { commonTemplateDownload } from '@/api/common.js'
  58. import operation_mixin from '@/components/template/operation_mixin.js'
  59. import { required, requiredValueMin } from '@/components/template/rules_verify.js'
  60. import { getWebsit } from '@/api/customerManagement.js'
  61. import { EventBus } from '@/utils/eventBus'
  62. import ImageUpload from '@/components/file-upload'
  63. export default {
  64. components: { TemplatePage },
  65. mixins: [import_mixin, operation_mixin],
  66. data() {
  67. return {
  68. // 表格属性
  69. tableAttributes: {
  70. selectColumn: false
  71. },
  72. // 表格事件
  73. tableEvents: {
  74. 'selection-change': this.selectionChange
  75. },
  76. recordSelected: [],
  77. formBool: false,
  78. formType: 0,
  79. formData: {
  80. companyWechatId: '',
  81. companyWechatName: '',
  82. contractTemplateId: '',
  83. contractTemplateImg: '',
  84. contractTemplateName: '',
  85. contractTemplatePdf: [],
  86. contractType: '',
  87. createBy: '',
  88. createTime: '',
  89. expireDate: '',
  90. fadadaTemplateId: '',
  91. followContractTemplateId: '',
  92. items: [],
  93. remark: '',
  94. status: '',
  95. updateBy: '',
  96. updateTime: '',
  97. validDate: ''
  98. },
  99. formRules: {},
  100. contractTemplateMAIN: [],
  101. formInline: {
  102. websitId: '',
  103. websitName: ''
  104. },
  105. itemsList: []
  106. }
  107. },
  108. computed: {
  109. optionsEvensGroup() {
  110. return [
  111. [
  112. [
  113. this.optionsEvensAuth('add', {
  114. click: () => {
  115. this.openWindow(() => {
  116. this.formType = 0
  117. this.formBool = true
  118. })
  119. }
  120. })
  121. ]
  122. ]
  123. ]
  124. },
  125. items() {
  126. return [
  127. {
  128. name: 'el-input',
  129. md: 12,
  130. attributes: {
  131. placeholder: '请输入'
  132. },
  133. formItemAttributes: {
  134. label: '合同名称',
  135. prop: 'contractTemplateName',
  136. rules: [...required]
  137. }
  138. },
  139. {
  140. md: 12,
  141. name: 'el-radio',
  142. options: [
  143. { label: '主合同', value: 'MAIN' },
  144. { label: '合同附件', value: 'FOLLOW' }
  145. ],
  146. attributes: {},
  147. formItemAttributes: {
  148. label: '合同类型',
  149. prop: 'contractType',
  150. rules: [...required]
  151. }
  152. },
  153. {
  154. md: 6,
  155. name: 'el-date-picker',
  156. attributes: {
  157. style: 'width:100%',
  158. 'value-format': 'yyyy-MM-dd HH:mm:ss',
  159. type: 'date'
  160. },
  161. formItemAttributes: {
  162. label: '合同生效日期',
  163. prop: 'validDate',
  164. rules: [...required]
  165. },
  166. events: {
  167. change: value => {
  168. this.formData.expireDate = ''
  169. }
  170. }
  171. },
  172. {
  173. md: 6,
  174. name: 'el-date-picker',
  175. attributes: {
  176. style: 'width:100%',
  177. 'value-format': 'yyyy-MM-dd HH:mm:ss',
  178. type: 'date',
  179. 'picker-options': {
  180. disabledDate: time => {
  181. var data = this.formData?.validDate?.split(' ')?.[0]
  182. return time.getTime() < new Date(data ? `${data} 00:00:00` : '').getTime()
  183. }
  184. }
  185. },
  186. formItemAttributes: {
  187. label: '合同失效日期',
  188. prop: 'expireDate',
  189. rules: [...required]
  190. },
  191. events: {
  192. change: value => {
  193. var data = this.formData?.expireDate?.split(' ')?.[0]
  194. this.formData.expireDate = `${data} 23:59:59`
  195. }
  196. }
  197. },
  198. {
  199. isShow: this.formData.contractType == 'FOLLOW',
  200. name: 'el-select',
  201. md: 12,
  202. options: this.contractTemplateMAIN.map(item => ({ label: item.name, value: item.contractTemplateId })),
  203. attributes: {
  204. clearable: true,
  205. filterable: true,
  206. disabled: false,
  207. placeholder: '请输入'
  208. },
  209. formItemAttributes: {
  210. label: '附件所属合同',
  211. prop: 'followContractTemplateId',
  212. rules: [...required]
  213. }
  214. },
  215. {
  216. md: 24,
  217. isShow: true,
  218. name: 'slot-component',
  219. formItemAttributes: {
  220. label: '合同模板',
  221. prop: 'contractTemplatePdf',
  222. rules: [...required]
  223. },
  224. render: (h, { props, onInput }) => {
  225. var { value } = props
  226. return (
  227. <div>
  228. <ImageUpload fileList={this.formData.contractTemplatePdf} limit={1} fileType={['pdf']} />
  229. <h4 style="color:#ffa700">上传PDF文件</h4>
  230. </div>
  231. )
  232. }
  233. },
  234. {
  235. name: 'el-input',
  236. md: 6,
  237. attributes: {
  238. disabled: true,
  239. placeholder: '请输入'
  240. },
  241. formItemAttributes: {
  242. label: '创建人',
  243. prop: 'createBy'
  244. }
  245. },
  246. {
  247. name: 'el-input',
  248. md: 6,
  249. attributes: {
  250. disabled: true,
  251. placeholder: '请输入'
  252. },
  253. formItemAttributes: {
  254. label: '创建时间',
  255. prop: 'createTime'
  256. }
  257. },
  258. {
  259. name: 'el-input',
  260. md: 6,
  261. attributes: {
  262. disabled: true,
  263. placeholder: '请输入'
  264. },
  265. formItemAttributes: {
  266. label: '修改人',
  267. prop: 'updateBy'
  268. }
  269. },
  270. {
  271. name: 'el-input',
  272. md: 6,
  273. attributes: {
  274. disabled: true,
  275. placeholder: '请输入'
  276. },
  277. formItemAttributes: {
  278. label: '修改时间',
  279. prop: 'updateTime'
  280. }
  281. }
  282. ]
  283. },
  284. items2() {
  285. return [
  286. {
  287. name: 'slot-component',
  288. md: 24,
  289. attributes: {},
  290. formItemAttributes: { label: '', 'label-width': '0px', prop: 'items', rules: [...required] },
  291. render: (h, { props, onInput }) => {
  292. var { formData } = props
  293. return (
  294. <div>
  295. <div>
  296. <el-form
  297. size="mini"
  298. inline={true}
  299. value={this.formInline}
  300. onInput={v => {
  301. this.formInline = v
  302. }}
  303. label-width="0px"
  304. >
  305. <el-form-item label="">
  306. <el-input
  307. value={this.formInline.websitId}
  308. onInput={v => {
  309. this.formInline.websitId = v
  310. }}
  311. placeholder="网点编号"
  312. ></el-input>
  313. </el-form-item>
  314. <el-form-item label="">
  315. <el-input
  316. value={this.formInline.websitName}
  317. onInput={v => {
  318. this.formInline.websitName = v
  319. }}
  320. placeholder="网点名称"
  321. ></el-input>
  322. </el-form-item>
  323. <el-form-item>
  324. <el-button
  325. type="primary"
  326. onClick={() => {
  327. EventBus.$emit('handlePaginationCallBack11')
  328. }}
  329. >
  330. 查询
  331. </el-button>
  332. <el-button
  333. onClick={() => {
  334. this.formInline.websitId = ''
  335. this.formInline.websitName = ''
  336. }}
  337. >
  338. 重置
  339. </el-button>
  340. </el-form-item>
  341. </el-form>
  342. </div>
  343. <pagingTransfer
  344. handlePaginationCallBackKey="handlePaginationCallBack11"
  345. value={this.formData.items}
  346. onInput={v => {
  347. this.formData.items = v
  348. }}
  349. left-columns={[
  350. { id: 'belongCompanyCode', label: '所属公司编号', width: '160' },
  351. { id: 'subWebsitId', label: '网点编号', width: '120' },
  352. { id: 'name', label: '网点名称', width: '' }
  353. ]}
  354. right-columns={[
  355. { id: 'belongCompanyCode', label: '所属公司编号', width: '160' },
  356. { id: 'subWebsitId', label: '网点编号', width: '120' },
  357. { id: 'name', label: '网点名称', width: '' }
  358. ]}
  359. show-pagination={true}
  360. pagination-call-back={this.paginationCallback}
  361. title-texts={['待选项', '已选项']}
  362. min-height="300px"
  363. table-row-key={row => row.subWebsitId}
  364. />
  365. </div>
  366. )
  367. }
  368. }
  369. ]
  370. }
  371. },
  372. methods: {
  373. // 列表请求函数
  374. getList: contractTemplateList,
  375. exportList: contractTemplateListExport,
  376. // 表格列解析渲染数据更改
  377. columnParsing(item, defaultData) {
  378. return defaultData
  379. },
  380. // 获取勾选框数据
  381. selectionChange(data) {
  382. this.recordSelected = data
  383. },
  384. handleClose() {
  385. this.$refs?.pageRef?.refreshList()
  386. this.$data.formData = this.$options.data().formData
  387. this.formType = 0
  388. this.formBool = false
  389. this.itemsList = []
  390. },
  391. formConfirm() {
  392. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  393. if (valid) {
  394. ;(this.formType ? contractTemplateUpdate : contractTemplateAdd)({
  395. ...this.formData,
  396. contractTemplatePdf: this.formData?.contractTemplatePdf?.[0]?.url || ''
  397. }).then(res => {
  398. this.$message({ type: 'success', message: '配置成功!' })
  399. this.$refs.pageRef.refreshList()
  400. this.handleClose()
  401. })
  402. }
  403. })
  404. },
  405. operation() {
  406. return this.operationBtn({
  407. edit: {
  408. click: ({ row, index, column }) => {
  409. this.openWindow(() => {
  410. contractTemplateDetail({
  411. contractTemplateId: row.contractTemplateId
  412. }).then(res => {
  413. this.formData = {
  414. ...res.data,
  415. items: (res.data?.items || [])?.map(item => ({ ...item })),
  416. contractTemplatePdf: res.data?.contractTemplatePdf ? [{ url: res.data?.contractTemplatePdf }] : []
  417. }
  418. this.itemsList = (this.formData?.items || [])?.map(item => ({ ...item }))
  419. this.$nextTick(() => {
  420. this.formType = 1
  421. this.formBool = true
  422. })
  423. })
  424. })
  425. }
  426. },
  427. del: {
  428. prompt: '此操作将永久删除数据, 是否继续?',
  429. click: ({ row, index, column }) => {
  430. contractTemplateDel({
  431. contractTemplateId: row.contractTemplateId
  432. }).then(res => {
  433. this.$message({
  434. message: '删除成功',
  435. type: 'success'
  436. })
  437. this.$refs?.pageRef?.refreshList()
  438. })
  439. }
  440. },
  441. effective: {
  442. prompt: '是否将此合同设为有效?',
  443. conditions: ({ row, index, column }) => {
  444. return row.status === 'OFF'
  445. },
  446. click: ({ row, index, column }) => {
  447. contractTemplateStatus({
  448. contractTemplateId: row.contractTemplateId,
  449. status: 'ON'
  450. }).then(res => {
  451. this.$message({
  452. message: '设置成功',
  453. type: 'success'
  454. })
  455. this.$refs?.pageRef?.refreshList()
  456. })
  457. }
  458. },
  459. invalid: {
  460. prompt: '是否将此合同设为无效?',
  461. conditions: ({ row, index, column }) => {
  462. return row.status === 'ON'
  463. },
  464. click: ({ row, index, column }) => {
  465. contractTemplateStatus({
  466. contractTemplateId: row.contractTemplateId,
  467. status: 'OFF'
  468. }).then(res => {
  469. this.$message({
  470. message: '设置成功',
  471. type: 'success'
  472. })
  473. this.$refs?.pageRef?.refreshList()
  474. })
  475. }
  476. }
  477. })
  478. },
  479. openWindow(cb) {
  480. Promise.all([
  481. contractTemplateList({
  482. pageNum: 1,
  483. pageSize: -1,
  484. params: [{ param: 'a.contract_type', compare: '=', value: 'MAIN' }]
  485. })
  486. ]).then(([res1]) => {
  487. this.contractTemplateMAIN = res1.data.records
  488. this.$nextTick(() => {
  489. cb?.()
  490. })
  491. })
  492. },
  493. paginationCallback({ pageIndex, pageSize }) {
  494. return new Promise(resolve => {
  495. contractTemplateQueryRelaWebsit({ pageNum: pageIndex, pageSize: pageSize, ...this.formInline }).then(res => {
  496. resolve({
  497. total: res.data.total,
  498. data: [...this.itemsList, ...res.data.records]
  499. })
  500. })
  501. })
  502. }
  503. }
  504. }
  505. </script>
  506. <style lang="scss" scoped>
  507. .neibuview {
  508. box-sizing: border-box;
  509. padding-left: 16px;
  510. ::v-deep & > .zj-page-fill-scroll {
  511. box-sizing: border-box;
  512. padding-right: 16px;
  513. & > div:nth-child(1) {
  514. margin-top: 20px;
  515. }
  516. }
  517. }
  518. </style>