operateList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="app-container">
  3. <div class="app-title">当前机构:{{ clubTitle }} </div>
  4. <div class="app-header-search">
  5. <el-form class="demo-form-inline">
  6. <el-form-item label="姓名:" style="width:210px;float: left;">
  7. <el-input v-model="listQuery.linkName" placeholder="请输入姓名" maxlength="50" style="width:150px;" @keyup.enter.native="handleFilter" />
  8. </el-form-item>
  9. <el-form-item label="手机号:" style="width:200px;float: left;">
  10. <el-input v-model="listQuery.mobile" placeholder="请输入手机号" maxlength="11" style="width:130px" @keyup.enter.native="handleFilter" />
  11. </el-form-item>
  12. <el-form-item label="状态:" style="width:160px;float: left;">
  13. <el-select v-model="listQuery.status" placeholder="请选择" style="width:100px" value="" @change="handleFilter">
  14. <el-option label="全部" value="" />
  15. <el-option label="已绑定" value="2" />
  16. <el-option label="未绑定" value="1" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="添加时间:" style="width:410px;float: left;">
  20. <el-date-picker
  21. v-model="listQuery.beginAddTime"
  22. type="date"
  23. value-format="yyyy-MM-dd"
  24. placeholder="选择日期"
  25. style="width: 150px;"
  26. />
  27. <el-date-picker
  28. v-model="listQuery.endAddTime"
  29. type="date"
  30. value-format="yyyy-MM-dd"
  31. placeholder="选择日期"
  32. style="width: 150px;"
  33. />
  34. </el-form-item>
  35. <el-form-item style="width:100px;float: left;">
  36. <el-button type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
  37. </el-form-item>
  38. <el-form-item style="width:100px;float: left;">
  39. <el-button type="primary" @click="bindAddPeople()">添加运营人员</el-button>
  40. </el-form-item>
  41. </el-form>
  42. </div>
  43. <el-table
  44. v-loading="listLoading"
  45. :data="list"
  46. element-loading-text="Loading"
  47. border
  48. fit
  49. highlight-current-row
  50. :header-cell-style="{background:'#eef1f6',color:'#606266'}"
  51. >
  52. <el-table-column align="center" label="序号" width="50">
  53. <template slot-scope="scope">
  54. {{ ((pageNum-1)*listQuery.pageSize)+scope.$index+1 }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="账号" width="130" align="center" prop="account" />
  58. <el-table-column label="姓名" align="center" prop="linkName" />
  59. <el-table-column label="手机号码" width="110" align="center" prop="mobile" />
  60. <el-table-column label="邀请码" width="130" align="center" prop="invitationCode">
  61. <template slot-scope="{row}">
  62. <span v-if="row.invitationCode" style="text-align: center;float:left">{{ row.invitationCode }}</span>
  63. <span v-if="row.invitationCode" :style="{color: rexpStautsColor(row.effectiveFlag)}">{{ rexpStautsText(row.effectiveFlag) }}</span>
  64. <span v-else type="info">----</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column class-name="status-col" label="状态" width="50" align="center" prop="status">
  68. <template slot-scope="{row}">
  69. <i v-if="row.status === '2'" class="el-icon-success" style="color:#67C23A;font-size: 18px;" />
  70. <!-- <i v-else class="el-icon-error" style="color: #E6A23C;font-size: 20px;" /> -->
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="center" label="微信昵称" prop="nickName">
  74. <template slot-scope="{row}">
  75. <span v-if="row.nickName">{{ row.nickName }}</span>
  76. <span v-else>----</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="center" label="OpenID" prop="openid">
  80. <template slot-scope="{row}">
  81. <span v-if="row.openid">{{ row.openid }}</span>
  82. <span v-else>----</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column align="center" label="添加时间" prop="addTime">
  86. <template slot-scope="{row}">
  87. <span v-if="row.addTime">{{ row.addTime }}</span>
  88. <span v-else>----</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column align="center" label="绑定时间" prop="bindTime">
  92. <template slot-scope="{row}">
  93. <span v-if="row.bindTime">{{ row.bindTime }}</span>
  94. <span v-else>----</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  98. <template slot-scope="{row}">
  99. <el-button type="primary" size="mini" style="width: 90px;margin:5px 0 0 0;" @click="handleEdit(row)">编辑</el-button>
  100. <el-button v-if="row.status === '2'" type="primary" size="mini" style="width: 90px;margin:5px 0 0 0;" @click="handleUntying(row)">解绑</el-button>
  101. <el-button v-else type="primary" size="mini" style="width: 90px;margin:5px 0 0 0;" @click="handleGenerateCode(row)">{{ row.invitationCode ? '更新邀请码' : '生成邀请码' }}</el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <pagination v-show="total>20" :total="total" :page.sync="listQuery.index" :limit.sync="listQuery.pageSize" @pagination="initOperatorListData" />
  106. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="440px">
  107. <el-form ref="dataForm" :rules="rules" :model="editTemp" label-position="left" label-width="70px" style="width: 400px;">
  108. <el-form-item label="姓名" prop="linkName">
  109. <el-input v-model="editTemp.linkName" placeholder="请输入姓名" maxlength="11" />
  110. </el-form-item>
  111. <el-form-item label="手机号" prop="mobile">
  112. <el-input v-model="editTemp.mobile" placeholder="请输入手机号" maxlength="11" />
  113. </el-form-item>
  114. </el-form>
  115. <div slot="footer" class="dialog-footer">
  116. <el-button @click="dialogFormVisible = false">取消</el-button>
  117. <el-button type="primary" :loading="loadingbut" @click="handleCreateOperator()">{{ loadingbuttext }}</el-button>
  118. <el-button v-if="dialogStatus === 'add'" type="primary" @click="handlePreservOperator()">保存生成邀请码</el-button>
  119. </div>
  120. </el-dialog>
  121. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogVisible" width="20%">
  122. <span>{{ dialogVisibleText }}</span>
  123. <span slot="footer" class="dialog-footer">
  124. <el-button @click="dialogVisible = false">取 消</el-button>
  125. <el-button type="primary" :loading="loadingbut" @click="handleConfirm()">{{ loadingbuttext }}</el-button>
  126. </span>
  127. </el-dialog>
  128. <template>
  129. <el-backtop style="right: 40px; bottom: 40px;">
  130. <i class="el-icon-upload2" />
  131. </el-backtop>
  132. </template>
  133. </div>
  134. </template>
  135. <script>
  136. import { getOperatorList, updateOperatorCode, unbindOperator, preservOperator } from '@/api/club'
  137. import Pagination from '@/components/Pagination'
  138. export default {
  139. components: { Pagination },
  140. filters: {
  141. statusFilter(status) {
  142. const statusMap = {
  143. 1: 'success',
  144. 0: 'gray'
  145. }
  146. return statusMap[status]
  147. }
  148. },
  149. data() {
  150. return {
  151. pageNum: 0,
  152. list: null,
  153. clubTitle: this.$route.query.name,
  154. listLoading: true,
  155. total: 100,
  156. dialogVisible: false,
  157. dialogVisibleText: '',
  158. handleConfirmType: '',
  159. listQuery: {
  160. index: 1,
  161. pageSize: 20,
  162. clubID: this.$route.query.clubID,
  163. userID: this.$route.query.userID,
  164. userOrganizeID: this.$store.getters.organizeID,
  165. linkName: '',
  166. mobile: '',
  167. status: '',
  168. beginAddTime: '',
  169. endAddTime: ''
  170. },
  171. editTemp: {
  172. userOrganizeID: this.$store.getters.organizeID,
  173. linkName: '',
  174. mobile: ''
  175. },
  176. codeRemp: {},
  177. dialogFormVisible: false,
  178. dialogFormVisibles: false,
  179. dialogStatus: '',
  180. loadingbut: false,
  181. loadingbuttext: '确定',
  182. textMap: {
  183. add: '添加运营人员',
  184. edit: '编辑运营人员',
  185. update: '提示',
  186. untying: '解绑',
  187. generate: '生成邀请码',
  188. updateCode: '更新邀请码'
  189. },
  190. rules: {
  191. linkName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
  192. mobile: [
  193. { required: true, message: '手机号不能为空', trigger: 'blur' },
  194. {
  195. required: true,
  196. pattern: /^\d{11}|\d{13}$/,
  197. message: '手机号格式不正确',
  198. trigger: 'blur'
  199. }]
  200. }
  201. }
  202. },
  203. computed: {
  204. organizeID() {
  205. return this.$store.getters.organizeID
  206. }
  207. },
  208. created() {
  209. this.initOperatorListData()
  210. },
  211. methods: {
  212. initOperatorListData() {
  213. this.listLoading = true
  214. getOperatorList(this.listQuery).then(response => {
  215. const operatorListPage = response.data
  216. this.pageNum = operatorListPage.index
  217. this.list = operatorListPage.results
  218. this.total = operatorListPage.totalRecord
  219. this.listLoading = false
  220. })
  221. },
  222. handleGenerateCode(row) {
  223. this.dialogVisible = true
  224. if (row.invitationCode) {
  225. this.dialogStatus = 'updateCode'
  226. this.dialogVisibleText = '确定生成邀请码吗?生成后将会短信通知该运营人员。'
  227. } else {
  228. this.dialogStatus = 'generate'
  229. this.dialogVisibleText = '确定生成邀请码吗?生成后将会短信通知该运营人员。'
  230. }
  231. this.handleConfirmType = 'generate'
  232. this.codeRemp = {
  233. id: row.id,
  234. clubID: row.clubID,
  235. userID: row.userID,
  236. userOrganizeID: this.$store.getters.organizeID
  237. }
  238. },
  239. handleConfirm() {
  240. switch (this.handleConfirmType) {
  241. case 'untying':
  242. this.unbindOperators()
  243. break
  244. case 'generate':
  245. this.generateRequst()
  246. break
  247. }
  248. },
  249. generateRequst() {
  250. const params = this.codeRemp
  251. this.loadingbut = true
  252. this.loadingbuttext = '请稍候...'
  253. updateOperatorCode(params).then(response => {
  254. this.$message({ message: response.msg, type: 'success', center: true })
  255. this.loadingbut = false
  256. this.loadingbuttext = '确定'
  257. this.dialogVisible = false
  258. setTimeout(() => {
  259. this.initOperatorListData()
  260. }, 1000)
  261. })
  262. },
  263. handleUntying(row) {
  264. this.dialogVisible = true
  265. this.dialogStatus = 'untying'
  266. this.dialogVisibleText = '确定解绑该运营人员吗?'
  267. this.handleConfirmType = 'untying'
  268. this.editTemp = { userOrganizeID: this.$store.getters.organizeID, id: row.id, clubID: row.clubID, userID: row.userID }
  269. },
  270. unbindOperators() {
  271. const params = this.editTemp
  272. this.loadingbut = true
  273. this.loadingbuttext = '解绑中...'
  274. unbindOperator(params).then(response => {
  275. this.$message({ message: response.msg, type: 'success', center: true })
  276. this.dialogVisible = false
  277. this.loadingbut = false
  278. this.loadingbuttext = '确定'
  279. setTimeout(() => {
  280. this.initOperatorListData()
  281. }, 1000)
  282. })
  283. },
  284. bindAddPeople() { // 添加运营人员
  285. this.loadingbuttext = '保存'
  286. const addTemp = { clubID: this.listQuery.clubID, userID: this.listQuery.userID }
  287. this.editTemp = Object.assign({}, addTemp)
  288. console.log(this.editTemp)
  289. this.dialogStatus = 'add'
  290. this.dialogFormVisible = true
  291. this.$nextTick(() => {
  292. this.$refs['dataForm'].clearValidate()
  293. })
  294. },
  295. handleEdit(row) { // 编辑
  296. this.loadingbuttext = '保存'
  297. const rowTemp = { id: row.id, clubID: row.clubID, userID: row.userID, linkName: row.linkName, mobile: row.mobile }
  298. this.editTemp = Object.assign({}, rowTemp)
  299. console.log(this.editTemp)
  300. this.dialogStatus = 'edit'
  301. this.dialogFormVisible = true
  302. this.$nextTick(() => {
  303. this.$refs['dataForm'].clearValidate()
  304. })
  305. },
  306. handleCreateOperator() { // 保存
  307. this.$refs['dataForm'].validate((valid) => {
  308. if (valid) {
  309. const params = Object.assign({ userOrganizeID: this.$store.getters.organizeID, configFlag: 1 }, this.editTemp)
  310. this.loadingbut = true
  311. this.loadingbuttext = '保存中...'
  312. preservOperator(params).then(response => {
  313. this.$message({ message: response.msg, type: 'success', center: true })
  314. this.dialogFormVisible = false
  315. this.loadingbut = false
  316. this.loadingbuttext = '确定'
  317. setTimeout(() => {
  318. this.initOperatorListData()
  319. }, 3000)
  320. }).catch(() => {
  321. this.loadingbut = false
  322. this.loadingbuttext = '保存'
  323. })
  324. }
  325. })
  326. },
  327. handlePreservOperator() { // 保存并生成邀请码
  328. this.$refs['dataForm'].validate((valid) => {
  329. if (valid) {
  330. const Formobj = { userOrganizeID: this.$store.getters.organizeID, configFlag: 2 }
  331. const params = Object.assign(Formobj, this.editTemp)
  332. preservOperator(params).then(response => {
  333. this.dialogFormVisible = false
  334. this.$message({ message: response.msg, type: 'success', center: true })
  335. setTimeout(() => {
  336. this.initOperatorListData()
  337. }, 1000)
  338. })
  339. }
  340. })
  341. },
  342. handleFilter() {
  343. this.initOperatorListData()
  344. },
  345. rexpStautsText(status) {
  346. let text = ''
  347. switch (status) {
  348. case '1':
  349. text = '有效'
  350. break
  351. case '2':
  352. text = '已使用'
  353. break
  354. case '3':
  355. text = '已失效'
  356. break
  357. }
  358. return text
  359. },
  360. rexpStautsColor(status) {
  361. let textColor = ''
  362. switch (status) {
  363. case '1':
  364. textColor = '#E6A441'
  365. break
  366. case '2':
  367. textColor = '#417DE6'
  368. break
  369. case '3':
  370. textColor = '#C5C5C5'
  371. break
  372. }
  373. return textColor
  374. }
  375. }
  376. }
  377. </script>
  378. <style lang="scss">
  379. .app-title{
  380. line-height: 40px;
  381. font-size: 18px;
  382. font-weight: bold;
  383. color: #999999;
  384. margin-bottom:10px;
  385. color: #417DE6;
  386. }
  387. </style>