index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{ activeKey, data }">
  4. <div
  5. :style="{
  6. width: '100%',
  7. height: activeKey == 'list' ? '100%' : '0px',
  8. overflow: 'hidden'
  9. }"
  10. >
  11. <template-page
  12. ref="pageRef"
  13. :get-list="getList"
  14. :table-attributes="tableAttributes"
  15. :table-events="tableEvents"
  16. :operationColumnWidth="280"
  17. :options-evens-group="optionsEvensGroup"
  18. :moreParameters="moreParameters"
  19. :column-parsing="columnParsing"
  20. :operation="operation()"
  21. :exportList="exportList"
  22. >
  23. <div slot="moreSearch">
  24. <el-radio-group v-model="examineStatus" size="mini" @change="changeType">
  25. <el-radio-button label="">全部</el-radio-button>
  26. <el-radio-button label="WAIT">待审核</el-radio-button>
  27. <el-radio-button label="OK">审核通过</el-radio-button>
  28. <el-radio-button label="FAIL">驳回</el-radio-button>
  29. </el-radio-group>
  30. <br /><br />
  31. </div>
  32. </template-page>
  33. </div>
  34. <div v-if="~['examine', 'detail'].indexOf(activeKey)" style="box-sizing: border-box; padding: 16px">
  35. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  36. <zj-form-module
  37. title=""
  38. label-width="100px"
  39. :showPackUp="false"
  40. :form-data="formData"
  41. :form-items="formItems"
  42. >
  43. </zj-form-module>
  44. </zj-form-container>
  45. <div slot="footer" class="dialog-footer">
  46. <el-button
  47. v-if="formData.examineStatus == 'WAIT'"
  48. size="mini"
  49. type="primary"
  50. @click="audit('OK', data.removeTab)"
  51. >审核通过</el-button
  52. >
  53. <el-button
  54. v-if="formData.examineStatus == 'WAIT'"
  55. size="mini"
  56. type="danger"
  57. @click="audit('FAIL', data.removeTab)"
  58. >审核驳回</el-button
  59. >
  60. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  61. </div>
  62. </div>
  63. <div v-if="~['worker'].indexOf(activeKey)" style="box-sizing: border-box; padding: 16px">
  64. <el-form ref="workerForm" :model="workerForm" label-width="110px" size="small" label-position="left">
  65. <el-row :gutter="20">
  66. <el-col :span="6">
  67. <el-form-item label="入驻网点" :required="true">
  68. <el-select v-model="workerForm.websitId" placeholder="请选择" style="width: 100%">
  69. <el-option v-for="item in websitList" :key="item.websitId" :label="item.name" :value="item.websitId">
  70. </el-option>
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="6">
  75. <el-form-item label="姓名" :required="true">
  76. <el-input v-model="workerForm.name" placeholder="请输入"></el-input>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="6">
  80. <el-form-item label="身份证号码" :required="true">
  81. <el-input v-model="workerForm.idCard" placeholder="请输入"></el-input>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6">
  85. <el-form-item label="银行卡号">
  86. <el-input v-model="workerForm.bankAccount" placeholder="请输入"></el-input>
  87. </el-form-item>
  88. </el-col>
  89. <el-col :span="6">
  90. <el-form-item label="师傅编号" :required="true">
  91. <el-input v-model="workerForm.workerNumber" placeholder="请输入"></el-input>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="24">
  95. <el-form-item label="身份证正面照" :required="true">
  96. <ImageUpload :fileList="fileList" :limit="1" :isEdit="true" />
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="24" v-for="(item, index) in imgList" :key="index">
  100. <el-form-item :label="item.dictValue" :required="true">
  101. <ImageUpload :fileList="item.imgs" :limit="1" :isEdit="true" />
  102. </el-form-item>
  103. </el-col>
  104. </el-row>
  105. </el-form>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button @click="data.removeTab()">取 消</el-button>
  108. <el-button type="primary" @click="memberInner(data.removeTab)">确定</el-button>
  109. </div>
  110. </div>
  111. </template>
  112. </zj-tab-page>
  113. </template>
  114. <script>
  115. import TemplatePage from '@/components/template/template-page-1.vue'
  116. import import_mixin from '@/components/template/import_mixin.js'
  117. import ImageUpload from '@/components/file-upload'
  118. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  119. import {
  120. memberListService2,
  121. memberPageExport,
  122. getMemberDetail,
  123. memberAudit,
  124. memberInner,
  125. memberInsideInner,
  126. getWebsit
  127. } from '@/api/distributorManagement'
  128. import operation_mixin from '@/components/template/operation_mixin.js'
  129. import request from '@/utils/request'
  130. export default {
  131. components: { TemplatePage, ImageUpload },
  132. mixins: [import_mixin, operation_mixin],
  133. data() {
  134. return {
  135. // 事件组合
  136. optionsEvensGroup: [],
  137. // 表格属性
  138. tableAttributes: {
  139. // 启用勾选列
  140. selectColumn: false,
  141. 'row-class-name': this.tableRowClassName
  142. },
  143. // 表格事件
  144. tableEvents: {
  145. 'selection-change': this.selectionChange
  146. },
  147. // 勾选选中行
  148. recordSelected: [],
  149. /** 表单变量 */
  150. formDialogType: 0,
  151. formDialogTitles: ['审核', '详情'],
  152. formDialog: false,
  153. dialogVisible: false,
  154. formData: {
  155. type: '工程师',
  156. examineRemark: '',
  157. examineStatus: ''
  158. },
  159. examineStatus: '',
  160. websitList: [],
  161. workerForm: {
  162. websitId: '',
  163. userId: '',
  164. idCard: '',
  165. workerNumber: '',
  166. name: '',
  167. bankAccount: ''
  168. },
  169. fileList: [],
  170. imgList: []
  171. }
  172. },
  173. computed: {
  174. // 更多参数
  175. moreParameters() {
  176. return []
  177. },
  178. formItems() {
  179. return [
  180. {
  181. md: 12,
  182. isShow: true,
  183. name: 'el-select',
  184. options: [
  185. { label: '待审核', value: 'WAIT' },
  186. { label: '驳回', value: 'FAIL' },
  187. { label: '通过', value: 'OK' }
  188. ],
  189. attributes: { placeholder: '请输入', disabled: true },
  190. formItemAttributes: {
  191. label: '审核状态',
  192. prop: 'examineStatus',
  193. rules: []
  194. }
  195. },
  196. {
  197. md: 12,
  198. isShow: true,
  199. name: 'el-select',
  200. options: [
  201. { label: '业务员', value: 'SERVICE' },
  202. { label: '师傅', value: 'WORKER' },
  203. { label: '普通用户', value: 'GENERAL' }
  204. ],
  205. attributes: { disabled: true },
  206. formItemAttributes: {
  207. label: '用户类型',
  208. prop: 'type',
  209. rules: []
  210. }
  211. },
  212. {
  213. md: 12,
  214. isShow: true,
  215. name: 'el-input',
  216. attributes: { placeholder: '请输入', disabled: true },
  217. formItemAttributes: {
  218. label: '用户名称',
  219. prop: 'nickName',
  220. rules: []
  221. }
  222. },
  223. {
  224. md: 12,
  225. isShow: true,
  226. name: 'el-input',
  227. attributes: { placeholder: '请输入', disabled: true },
  228. formItemAttributes: {
  229. label: '联系电话',
  230. prop: 'mobile',
  231. rules: []
  232. }
  233. },
  234. {
  235. md: 12,
  236. isShow: true,
  237. name: 'el-input',
  238. attributes: { placeholder: '请输入', disabled: true },
  239. formItemAttributes: {
  240. label: '身份证号码',
  241. prop: 'idCard',
  242. rules: []
  243. }
  244. },
  245. {
  246. md: 12,
  247. isShow: true,
  248. name: 'slot-component',
  249. attributes: {},
  250. formItemAttributes: {
  251. label: '身份证',
  252. prop: 'idCardImg',
  253. rules: []
  254. },
  255. render: (h, { props, onInput }) => {
  256. var { value } = props
  257. console.log(this.formData.idCardImg)
  258. return this.formData.idCardImg ? (
  259. <el-image
  260. src={this.$showImgUrl(this.formData.idCardImg)}
  261. style="width: 120px;height:120px"
  262. preview-src-list={[this.$showImgUrl(this.formData.idCardImg)]}
  263. fit="cover"
  264. ></el-image>
  265. ) : (
  266. ''
  267. )
  268. }
  269. },
  270. {
  271. md: 24,
  272. isShow: true,
  273. name: 'el-input',
  274. attributes: {
  275. placeholder: '请输入',
  276. type: 'textarea',
  277. disabled: this.formData.examineStatus == 'WAIT' ? false : true
  278. },
  279. formItemAttributes: {
  280. label: '备注',
  281. prop: 'examineRemark',
  282. rules: []
  283. }
  284. }
  285. ]
  286. }
  287. },
  288. created() {
  289. this.getImgList()
  290. },
  291. methods: {
  292. // 切换状态
  293. changeType(val) {
  294. this.$refs.pageRef.refreshList()
  295. },
  296. exportList: memberPageExport,
  297. // 列表请求函数
  298. getList(p) {
  299. try {
  300. var pam = JSON.parse(JSON.stringify(p))
  301. if (this.examineStatus) {
  302. pam.params.push({ param: 'a.examine_status', compare: '=', value: this.examineStatus })
  303. }
  304. return memberListService2(pam)
  305. } catch (error) {
  306. console.log(error)
  307. }
  308. },
  309. getImgList() {
  310. request({
  311. url: `/dictCompany/page`,
  312. method: 'post',
  313. data: { pageNum: 1, pageSize: -1, params: [{ param: 'a.dict_type', compare: '=', value: 'WORKER_IMG' }] }
  314. }).then(res => {
  315. this.imgList = res.data.records.filter(item => {
  316. return (item.imgs = [])
  317. })
  318. })
  319. },
  320. // 列表导出函数
  321. exportList: memberPageExport,
  322. // 表格列解析渲染数据更改
  323. columnParsing(item, defaultData) {
  324. if (item.jname === 'idCardImg') {
  325. defaultData.render = (h, { row, index, column }) => {
  326. return (
  327. <div style="padding:0 6px;cursor: pointer;">
  328. {' '}
  329. {row.idCardImg
  330. ? row.idCardImg
  331. .split(',')
  332. .map(url => (
  333. <el-image
  334. src={this.$showImgUrl(url)}
  335. preview-src-list={[this.$showImgUrl(url)]}
  336. fit="fit"
  337. style="width:80px;height:80px;"
  338. />
  339. ))
  340. : null}{' '}
  341. </div>
  342. )
  343. }
  344. }
  345. return defaultData
  346. },
  347. // 监听勾选变化
  348. selectionChange(data) {
  349. this.recordSelected = data
  350. },
  351. guanbi() {
  352. this.$refs?.formRef?.$refs?.inlineForm?.clearValidate()
  353. this.$data.formData = this.$options.data().formData
  354. },
  355. tableRowClassName({ row, rowIndex }) {
  356. if (row.examineStatus === '待审核') {
  357. return 'redbackground'
  358. } else {
  359. return ''
  360. }
  361. },
  362. // 表格操作列
  363. operation() {
  364. return this.operationBtn({
  365. detail: {
  366. btnType: 'text',
  367. click: ({ row, index, column }) => {
  368. this.$refs.tabPage.addTab({
  369. activeKey: 'detail',
  370. key: 'detail',
  371. label: '详情',
  372. triggerEvent: () => {
  373. this.guanbi()
  374. this.$nextTick(() => {
  375. getMemberDetail({ userId: row.userId }).then(res => {
  376. Object.assign(this.formData, res.data)
  377. this.formDialogType = 1
  378. })
  379. })
  380. }
  381. })
  382. }
  383. },
  384. examine: {
  385. btnType: 'text',
  386. conditions: ({ row, index, column }) => {
  387. return row.examineStatus == 'WAIT'
  388. },
  389. click: ({ row, index, column }) => {
  390. this.$refs.tabPage.addTab({
  391. activeKey: 'examine',
  392. key: 'examine',
  393. label: '审核',
  394. triggerEvent: () => {
  395. this.guanbi()
  396. this.$nextTick(() => {
  397. this.workerForm.userId = row.userId
  398. getMemberDetail({ userId: row.userId }).then(res => {
  399. Object.assign(this.formData, res.data)
  400. })
  401. })
  402. },
  403. closeEvent: () => {}
  404. })
  405. }
  406. },
  407. setWorker: {
  408. btnType: 'text',
  409. // prompt: '请确认是否设为工程师?',
  410. conditions: ({ row, index, column }) => {
  411. return row.examineStatus != 'WAIT'
  412. },
  413. click: ({ row, index, column }) => {
  414. this.$refs.tabPage.addTab({
  415. activeKey: 'worker',
  416. key: 'worker',
  417. label: '设为工程师',
  418. triggerEvent: () => {
  419. this.guanbi()
  420. this.$nextTick(() => {
  421. this.workerForm.userId = row.userId
  422. getWebsit({ type: 'C' }).then(res => {
  423. this.websitList = res.data
  424. this.dialogVisible = true
  425. })
  426. })
  427. },
  428. closeEvent: () => {}
  429. })
  430. }
  431. },
  432. setCustomer: {
  433. btnType: 'text',
  434. prompt: '请确认是否设为客户?',
  435. click: ({ row, index, column }) => {
  436. memberInner({
  437. type: 'GENERAL',
  438. userId: row.userId
  439. }).then(res => {
  440. if (res.code == 200) {
  441. this.$message({ type: 'success', message: '设为客户成功!' })
  442. this.$refs.pageRef.refreshList()
  443. } else {
  444. this.$message.error(res.msg)
  445. }
  446. })
  447. }
  448. },
  449. setService: {
  450. name: ({ row, index, column }) => {
  451. return `${row.innerr ? '取消' : '设为'}内部分销员`
  452. },
  453. btnType: 'text',
  454. prompt: ({ row, index, column }) => {
  455. return `请确认是否${row.innerr ? '取消' : '设为'}内部分销员?`
  456. },
  457. click: ({ row, index, column }) => {
  458. memberInsideInner({
  459. innerr: !row.innerr,
  460. userIds: row.userId
  461. }).then(res => {
  462. if (res.code == 200) {
  463. this.$message({ type: 'success', message: (row.innerr ? '取消' : '设为') + '内部分销员成功!' })
  464. this.$refs.pageRef.refreshList()
  465. } else {
  466. this.$message.error(res.msg)
  467. }
  468. })
  469. }
  470. }
  471. })
  472. },
  473. addData() {
  474. this.formDialogType = 0
  475. this.openForm()
  476. },
  477. openForm() {
  478. this.formDialog = true
  479. },
  480. formCancel() {
  481. this.$refs.formRef.$refs.inlineForm.clearValidate()
  482. this.$data.formData = this.$options.data().formData
  483. this.formDialog = false
  484. },
  485. audit(examineStatusEnum, removeTab) {
  486. memberAudit({
  487. examineStatusEnum,
  488. examineRemark: this.formData.examineRemark,
  489. id: this.formData.id,
  490. userId: this.workerForm.userId
  491. }).then(res => {
  492. this.$message({ type: 'success', message: '审核成功!' })
  493. this.formCancel()
  494. removeTab('list')
  495. this.$refs.pageRef.refreshList()
  496. })
  497. },
  498. memberInner(removeTab) {
  499. let workerImgs = []
  500. for (var i = 0; i < this.imgList.length; i++) {
  501. if (this.imgList[i].imgs.length == 0) {
  502. return this.$message({ type: 'error', message: '请上传' + this.imgList[i].dictValue + '!' })
  503. break
  504. } else {
  505. workerImgs.push({
  506. imgName: this.imgList[i].dictValue,
  507. imgUrl: this.imgList[i].imgs.length > 0 ? this.imgList[i].imgs[0].url : ''
  508. })
  509. }
  510. }
  511. if (!this.workerForm.websitId) {
  512. return this.$message({ type: 'error', message: '请选择入驻网点!' })
  513. } else if (!this.workerForm.name) {
  514. return this.$message({ type: 'error', message: '请输入姓名!' })
  515. } else if (!this.workerForm.workerNumber) {
  516. return this.$message({ type: 'error', message: '请输入师傅编号!' })
  517. } else if (!this.workerForm.idCard) {
  518. return this.$message({ type: 'error', message: '请输入身份证号码!' })
  519. } else if (!/^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}[\dXx]$/g.test(this.workerForm.idCard)) {
  520. return this.$message({ type: 'error', message: '请输入正确的身份证号码!' })
  521. } else if (this.fileList.length == 0) {
  522. return this.$message({ type: 'error', message: '请上传身份证正面照!' })
  523. }
  524. memberInner({
  525. type: 'WORKER',
  526. userId: this.workerForm.userId,
  527. websitId: this.workerForm.websitId,
  528. name: this.workerForm.name,
  529. idCard: this.workerForm.idCard,
  530. workerNumber: this.workerForm.workerNumber,
  531. bankAccount: this.workerForm.bankAccount,
  532. idCardImg: this.fileList.map(item => item.url).join(','),
  533. workerImgs
  534. }).then(res => {
  535. removeTab('list')
  536. this.dialogVisible = false
  537. this.$message({ type: 'success', message: '设置工程师成功!' })
  538. this.$refs.pageRef.refreshList()
  539. })
  540. },
  541. formConfirm() {
  542. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  543. if (valid) {
  544. ;[memberAudit][this.formDialogType](this.formData).then(res => {
  545. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  546. this.formCancel()
  547. this.$refs.pageRef.refreshList()
  548. })
  549. }
  550. })
  551. }
  552. }
  553. }
  554. </script>
  555. <style lang="scss" scoped></style>
  556. <style lang="scss">
  557. .redbackground {
  558. background: rgb(248, 185, 185) !important;
  559. }
  560. .lcsebackground {
  561. background: rgb(212, 245, 212) !important;
  562. }
  563. </style>