index.vue 15 KB

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