index.vue 14 KB

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