index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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="260"
  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. <el-dialog
  33. title="绑定辅助师傅"
  34. width="500px"
  35. :modal="true"
  36. :visible.sync="formDialogaddsf"
  37. :show-close="true"
  38. :close-on-click-modal="false"
  39. :before-close="formCancelaa"
  40. >
  41. <zj-form-container
  42. ref="formRefaa"
  43. :form-data="formDataaa"
  44. :styleSwitch="false"
  45. :formAttributes="{
  46. 'label-position': 'top'
  47. }"
  48. >
  49. <zj-form-module
  50. title="绑定辅助师傅"
  51. label-width="100px"
  52. :showHade="false"
  53. :form-data="formDataaa"
  54. :form-items="formItemsaa"
  55. >
  56. </zj-form-module>
  57. </zj-form-container>
  58. <div slot="footer">
  59. <el-button size="mini" @click="formCancelaa">取 消</el-button>
  60. <el-button size="mini" @click="queding">确 定</el-button>
  61. </div>
  62. </el-dialog>
  63. </template-page>
  64. </div>
  65. <div v-if="~['examine', 'detail'].indexOf(activeKey)" style="box-sizing: border-box; padding: 16px">
  66. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  67. <zj-form-module
  68. :title="data.label"
  69. label-width="170px"
  70. :showPackUp="false"
  71. :form-data="formData"
  72. :form-items="[...formItems, ...imageList]"
  73. >
  74. </zj-form-module>
  75. </zj-form-container>
  76. <div slot="footer" class="dialog-footer">
  77. <el-button
  78. v-if="formData.examineStatus == 'WAIT' && activeKey == 'examine'"
  79. size="mini"
  80. type="primary"
  81. @click="audit('OK', data.removeTab)"
  82. >审核通过</el-button
  83. >
  84. <el-button
  85. v-if="formData.examineStatus == 'WAIT' && activeKey == 'examine'"
  86. size="mini"
  87. type="danger"
  88. @click="audit('FAIL', data.removeTab)"
  89. >审核驳回</el-button
  90. >
  91. <el-button v-if="activeKey == 'detail'" size="mini" type="primary" @click="update(data.removeTab)"
  92. >保存</el-button
  93. >
  94. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  95. </div>
  96. </div>
  97. </template>
  98. </zj-tab-page>
  99. </template>
  100. <script>
  101. import TemplatePage from '@/components/template/template-page-1.vue'
  102. import import_mixin from '@/components/template/import_mixin.js'
  103. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  104. import {
  105. memberSlaveBind,
  106. memberListPageV2,
  107. memberPageExport,
  108. getMemberDetail,
  109. memberAudit,
  110. memberInner,
  111. update
  112. } from '@/api/masterManagement'
  113. import operation_mixin from '@/components/template/operation_mixin.js'
  114. import ImageUpload from '@/components/file-upload'
  115. export default {
  116. components: { TemplatePage, ImageUpload },
  117. mixins: [import_mixin, operation_mixin],
  118. data() {
  119. return {
  120. // 事件组合
  121. optionsEvensGroup: [],
  122. // 表格属性
  123. tableAttributes: {
  124. // 启用勾选列
  125. selectColumn: false,
  126. 'row-class-name': this.tableRowClassName
  127. },
  128. // 表格事件
  129. tableEvents: {
  130. 'selection-change': this.selectionChange
  131. },
  132. // 勾选选中行
  133. recordSelected: [],
  134. /** 表单变量 */
  135. formData: {
  136. type: '工程师',
  137. nickName: '',
  138. mobile: '',
  139. idCard: '',
  140. bankAccount: '',
  141. isEs: false,
  142. examineRemark: '',
  143. examineStatus: '',
  144. isRecycler: '',
  145. idCardImg: []
  146. },
  147. examineStatus: '',
  148. formDialogaddsf: false,
  149. formDataaa: {
  150. slaveUserId: '',
  151. userId: '',
  152. websitId: ''
  153. },
  154. suoyoushifu: [],
  155. imageList: []
  156. }
  157. },
  158. computed: {
  159. // 更多参数
  160. moreParameters() {
  161. return []
  162. },
  163. formItems() {
  164. return [
  165. {
  166. md: 12,
  167. isShow: true,
  168. name: 'el-select',
  169. options: [
  170. { label: '待审核', value: 'WAIT' },
  171. { label: '驳回', value: 'FAIL' },
  172. { label: '通过', value: 'OK' }
  173. ],
  174. attributes: { placeholder: '请输入', disabled: true },
  175. formItemAttributes: {
  176. label: '审核状态',
  177. prop: 'examineStatus',
  178. rules: []
  179. }
  180. },
  181. {
  182. md: 12,
  183. isShow: true,
  184. name: 'el-input',
  185. attributes: { disabled: true },
  186. formItemAttributes: {
  187. label: '用户类型',
  188. prop: 'type',
  189. rules: []
  190. }
  191. },
  192. {
  193. md: 12,
  194. isShow: true,
  195. name: 'el-input',
  196. attributes: { placeholder: '请输入' },
  197. formItemAttributes: {
  198. label: '用户名称',
  199. prop: 'nickName',
  200. rules: [...required]
  201. }
  202. },
  203. {
  204. md: 12,
  205. isShow: true,
  206. name: 'el-input',
  207. attributes: { placeholder: '请输入', disabled: true },
  208. formItemAttributes: {
  209. label: '联系电话',
  210. prop: 'mobile',
  211. rules: []
  212. }
  213. },
  214. {
  215. md: 12,
  216. isShow: true,
  217. name: 'el-input',
  218. attributes: { placeholder: '请输入' },
  219. formItemAttributes: {
  220. label: '身份证号码',
  221. prop: 'idCard',
  222. rules: [...required]
  223. }
  224. },
  225. {
  226. md: 12,
  227. isShow: true,
  228. name: 'slot-component',
  229. attributes: {},
  230. formItemAttributes: {
  231. label: '身份证',
  232. prop: 'idCardImg',
  233. rules: [...required]
  234. },
  235. render: (h, { props, onInput }) => {
  236. var { value } = props
  237. console.log(this.formData.idCardImg)
  238. return (
  239. <ImageUpload fileList={this.formData.idCardImg} limit={1} isEdit={true} />
  240. // this.formData.idCardImg ? <el-image src={this.formData.idCardImg} style='width: 120px;height:120px' preview-src-list={[this.formData.idCardImg]} fit="cover"></el-image> : ''
  241. )
  242. }
  243. },
  244. {
  245. md: 12,
  246. isShow: true,
  247. name: 'el-input',
  248. attributes: { placeholder: '请输入', disabled: true },
  249. formItemAttributes: {
  250. label: '所属商户',
  251. prop: 'companyName',
  252. rules: []
  253. }
  254. },
  255. {
  256. md: 12,
  257. isShow: true,
  258. name: 'el-input',
  259. attributes: { placeholder: '请输入', disabled: true },
  260. formItemAttributes: {
  261. label: '入驻网点',
  262. prop: 'websitName',
  263. rules: []
  264. }
  265. },
  266. {
  267. md: 12,
  268. isShow: true,
  269. name: 'el-input',
  270. attributes: { placeholder: '请输入' },
  271. formItemAttributes: {
  272. label: '银行卡',
  273. prop: 'bankAccount',
  274. rules: []
  275. }
  276. },
  277. {
  278. md: 6,
  279. isShow: true,
  280. name: 'slot-component',
  281. attributes: {},
  282. formItemAttributes: {
  283. label: '是否允许二手商城发布',
  284. prop: 'isEs',
  285. rules: [...required]
  286. },
  287. render: (h, { props, onInput }) => {
  288. var { value } = props
  289. return (
  290. <el-radio-group v-model={this.formData.isEs}>
  291. <el-radio label={true}>是</el-radio>
  292. <el-radio label={false}>否</el-radio>
  293. </el-radio-group>
  294. )
  295. }
  296. },
  297. {
  298. md: 6,
  299. isShow: true,
  300. name: 'slot-component',
  301. attributes: {},
  302. formItemAttributes: {
  303. label: '是否回收员',
  304. prop: 'isRecycler',
  305. rules: [...required]
  306. },
  307. render: (h, { props, onInput }) => {
  308. var { value } = props
  309. return (
  310. <el-radio-group v-model={this.formData.isRecycler}>
  311. <el-radio label={true}>是</el-radio>
  312. <el-radio label={false}>否</el-radio>
  313. </el-radio-group>
  314. )
  315. }
  316. },
  317. {
  318. md: 24,
  319. isShow: true,
  320. name: 'el-input',
  321. attributes: {
  322. placeholder: '请输入',
  323. type: 'textarea',
  324. disabled: this.formData.examineStatus == 'WAIT' ? false : true
  325. },
  326. formItemAttributes: {
  327. label: '备注',
  328. prop: 'examineRemark',
  329. rules: []
  330. }
  331. }
  332. ]
  333. },
  334. formItemsaa() {
  335. return [
  336. {
  337. md: 24,
  338. isShow: true,
  339. name: 'el-select',
  340. options: this.suoyoushifu,
  341. attributes: { placeholder: '请输入' },
  342. formItemAttributes: {
  343. label: '选择师傅',
  344. prop: 'slaveUserId',
  345. rules: [...required]
  346. },
  347. events: {
  348. change: val => {
  349. if (val) {
  350. this.formDataaa.websitId = this.suoyoushifu.find(item => item.value == val)?.websitId
  351. } else {
  352. this.formDataaa.websitId = ''
  353. }
  354. }
  355. }
  356. }
  357. ]
  358. }
  359. },
  360. methods: {
  361. queding() {
  362. this.$refs.formRefaa.validate((valid, invalidFields, errLabels) => {
  363. if (valid) {
  364. memberSlaveBind(this.formDataaa).then(res => {
  365. this.$message({
  366. type: 'success',
  367. message: '绑定成功成功'
  368. })
  369. this.formCancelaa()
  370. this.$refs.pageRef.refreshList()
  371. })
  372. }
  373. })
  374. },
  375. formCancelaa() {
  376. this.$refs?.formRefaa?.$refs?.inlineForm?.clearValidate()
  377. this.$data.formDataaa = this.$options.data().formDataaa
  378. this.formDialogaddsf = false
  379. },
  380. // 切换状态
  381. changeType(val) {
  382. this.$refs.pageRef.refreshList()
  383. },
  384. exportList: memberPageExport,
  385. // 列表请求函数
  386. getList(p) {
  387. try {
  388. var pam = JSON.parse(JSON.stringify(p))
  389. if (this.examineStatus) {
  390. pam.params.push({ param: 'b.examine_status', compare: '=', value: this.examineStatus })
  391. }
  392. return memberListPageV2(pam)
  393. } catch (error) {
  394. console.log(error)
  395. }
  396. },
  397. // 列表导出函数
  398. exportList: memberPageExport,
  399. // 表格列解析渲染数据更改
  400. columnParsing(item, defaultData) {
  401. if (item.jname === 'idCardImg') {
  402. defaultData.render = (h, { row, index, column }) => {
  403. return (
  404. <div style="padding:0 6px;cursor: pointer;">
  405. {row.idCardImg
  406. ? row.idCardImg
  407. .split(',')
  408. .map(url => (
  409. <el-image
  410. src={this.$showImgUrl(url)}
  411. preview-src-list={[this.$showImgUrl(url)]}
  412. fit="fit"
  413. style="width:80px;height:80px;"
  414. />
  415. ))
  416. : null}
  417. </div>
  418. )
  419. }
  420. }
  421. return defaultData
  422. },
  423. // 监听勾选变化
  424. selectionChange(data) {
  425. this.recordSelected = data
  426. },
  427. // 表格操作列
  428. operation() {
  429. return this.operationBtn({
  430. detail: {
  431. btnType: 'text',
  432. click: ({ row, index, column }) => {
  433. this.$refs.tabPage.addTab({
  434. activeKey: 'detail',
  435. key: 'detail',
  436. label: '详情',
  437. triggerEvent: () => {
  438. this.guanbi()
  439. this.imageList = []
  440. this.$nextTick(() => {
  441. getMemberDetail({ id: row.id }).then(res => {
  442. Object.assign(this.formData, res.data, {
  443. idCardImg: [{ url: res.data.idCardImg }]
  444. })
  445. res.data.workerImgList.forEach(item => {
  446. this.imageList.push({
  447. md: 12,
  448. isShow: true,
  449. name: 'slot-component',
  450. attributes: {},
  451. formItemAttributes: {
  452. label: item.imgName,
  453. prop: 'imgName',
  454. rules: []
  455. },
  456. render: (h, { props, onInput }) => {
  457. var { value } = props
  458. return item.imgUrl ? (
  459. <el-image
  460. src={this.$showImgUrl(item.imgUrl)}
  461. style="width: 120px;height:120px"
  462. preview-src-list={[this.$showImgUrl(item.imgUrl)]}
  463. fit="cover"
  464. ></el-image>
  465. ) : (
  466. ''
  467. )
  468. }
  469. })
  470. })
  471. })
  472. })
  473. },
  474. closeEvent: () => {}
  475. })
  476. }
  477. },
  478. examine: {
  479. btnType: 'text',
  480. conditions: ({ row, index, column }) => {
  481. return row.examineStatus == 'WAIT'
  482. },
  483. click: ({ row, index, column }) => {
  484. this.$refs.tabPage.addTab({
  485. activeKey: 'examine',
  486. key: 'examine',
  487. label: '审核',
  488. triggerEvent: () => {
  489. this.guanbi()
  490. this.$nextTick(() => {
  491. getMemberDetail({ id: row.id }).then(res => {
  492. Object.assign(this.formData, res.data, {
  493. idCardImg: [{ url: res.data.idCardImg }]
  494. })
  495. })
  496. })
  497. },
  498. closeEvent: () => {}
  499. })
  500. }
  501. },
  502. setService: {
  503. btnType: 'text',
  504. prompt: '请确认是否设为分销员?',
  505. click: ({ row, index, column }) => {
  506. memberInner({
  507. type: 'SERVICE',
  508. userId: row.userId
  509. }).then(res => {
  510. if (res.code == 200) {
  511. this.$message({ type: 'success', message: '设为分销员成功!' })
  512. this.$refs.pageRef.refreshList()
  513. } else {
  514. this.$message.error(res.msg)
  515. }
  516. })
  517. }
  518. },
  519. setCustomer: {
  520. btnType: 'text',
  521. prompt: '请确认是否设为客户?',
  522. click: ({ row, index, column }) => {
  523. memberInner({
  524. type: 'GENERAL',
  525. userId: row.userId
  526. }).then(res => {
  527. if (res.code == 200) {
  528. this.$message({ type: 'success', message: '设为客户成功!' })
  529. this.$refs.pageRef.refreshList()
  530. } else {
  531. this.$message.error(res.msg)
  532. }
  533. })
  534. }
  535. },
  536. bindWorker: {
  537. btnType: 'text',
  538. conditions: ({ row, index, column }) => {
  539. return row.examineStatus == 'OK'
  540. },
  541. click: ({ row, index, column }) => {
  542. memberListPageV2({
  543. pageNum: 1,
  544. pageSize: -1,
  545. params: [
  546. { param: 'b.examine_status', compare: '=', value: 'OK' },
  547. { param: 'b.websit_id', compare: '=', value: row.websitId }
  548. ]
  549. }).then(res => {
  550. this.suoyoushifu = res.data.records
  551. .filter(item => item.id != row.id)
  552. .map(item => ({
  553. label: item.nickName,
  554. value: item.userId,
  555. websitId: item.websitId
  556. }))
  557. this.formDataaa.userId = row.userId
  558. this.formDialogaddsf = true
  559. })
  560. }
  561. }
  562. })
  563. },
  564. tableRowClassName({ row, rowIndex }) {
  565. if (row.examineStatus === '待审核') {
  566. return 'redbackground'
  567. } else {
  568. return ''
  569. }
  570. },
  571. guanbi() {
  572. this.$refs?.formRef?.$refs?.inlineForm?.clearValidate()
  573. this.$data.formData = this.$options.data().formData
  574. },
  575. audit(examineStatusEnum, removeTab) {
  576. memberAudit({
  577. examineStatusEnum,
  578. examineRemark: this.formData.examineRemark,
  579. id: this.formData.id
  580. }).then(res => {
  581. this.$message({ type: 'success', message: '审核成功!' })
  582. removeTab('list')
  583. this.$refs.pageRef.refreshList()
  584. })
  585. },
  586. update(removeTab) {
  587. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  588. if (valid) {
  589. update({
  590. userId: this.formData.userId,
  591. websitId: this.formData.websitId,
  592. bankAccount: this.formData.bankAccount,
  593. isEs: this.formData.isEs,
  594. isRecycler: this.formData.isRecycler,
  595. idCard: this.formData.idCard,
  596. idCardImg: this.formData.idCardImg[0].url,
  597. name: this.formData.nickName
  598. }).then(res => {
  599. this.$message({ type: 'success', message: '保存成功!' })
  600. removeTab('list')
  601. this.$refs.pageRef.refreshList()
  602. })
  603. }
  604. })
  605. }
  606. }
  607. }
  608. </script>
  609. <style lang="scss" scoped>
  610. .tab {
  611. padding: 20px 20px 0 20px;
  612. }
  613. </style>
  614. <style lang="scss">
  615. .redbackground {
  616. background: rgb(248, 185, 185) !important;
  617. }
  618. .lcsebackground {
  619. background: rgb(212, 245, 212) !important;
  620. }
  621. </style>