list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="app-container">
  3. <div class="app-header-search">
  4. <el-form ref="searchForm" :inline="true" :model="searchForm" class="demo-form-inline">
  5. <el-form-item label="会所名称:">
  6. <el-input v-model="searchForm.name" placeholder="请输入会所名称" maxlength="50" style="width:200px" />
  7. </el-form-item>
  8. <el-form-item label="联系人:">
  9. <el-input v-model="searchForm.linkName" placeholder="请输入联系人姓名" maxlength="10" style="width:150px" />
  10. </el-form-item>
  11. <el-form-item label="手机号:">
  12. <el-input v-model="searchForm.mobile" placeholder="请输入手机号" maxlength="11" style="width:130px" />
  13. </el-form-item>
  14. <el-form-item label="上线状态:">
  15. <el-select v-model="searchForm.clubStatus" placeholder="请选择" style="width:100px">
  16. <el-option label="已上线" value="90" />
  17. <el-option label="已下线" value="91" />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="创建时间:">
  21. <el-date-picker
  22. v-model="startTime"
  23. type="date"
  24. placeholder="选择日期"
  25. format="yyyy 年 MM 月 dd 日"
  26. value-format="yyyy-MM-dd"
  27. />
  28. <el-date-picker
  29. v-model="endTime"
  30. type="date"
  31. placeholder="选择日期"
  32. format="yyyy 年 MM 月 dd 日"
  33. value-format="yyyy-MM-dd"
  34. />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="success" @click="onSubmit">搜索</el-button>
  38. </el-form-item>
  39. <el-form-item>
  40. <router-link :to="'/club/form/'">
  41. <el-button type="primary" @click="onSubmit">上线会所</el-button>
  42. </router-link>
  43. </el-form-item>
  44. </el-form>
  45. </div>
  46. <el-table
  47. v-loading="listLoading"
  48. :data="list"
  49. element-loading-text="Loading"
  50. border
  51. fit
  52. highlight-current-row
  53. :header-cell-style="{background:'#eef1f6',color:'#606266'}"
  54. >
  55. <el-table-column align="center" label="序号" width="50">
  56. <template slot-scope="scope">
  57. {{ scope.$index+1 }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="账号" width="150" align="center" prop="account" />
  61. <el-table-column label="会所名称" width="150" align="center" prop="name" />
  62. <el-table-column label="联系人" width="80" align="center" prop="linkMan" />
  63. <el-table-column label="手机号" width="110" align="center" prop="bindMobile" />
  64. <el-table-column class-name="status-col" label="上线状态" width="150" align="center" prop="status">
  65. <template slot-scope="{row}">
  66. <el-tag>
  67. {{ row.clubStatus === '91' ? '已下线' : '已上线' }}
  68. </el-tag>
  69. <el-button v-if="row.clubStatus === '91'" type="primary" size="mini" @click="handOnline(row)">上线</el-button>
  70. <el-button v-else type="primary" size="mini" @click="handOffline(row)">下线</el-button>
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="center" label="会所地址" width="350" prop="address" />
  74. <el-table-column align="center" label="创建时间" width="180" prop="registerTime" />
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  76. <template slot-scope="{row}">
  77. <router-link :to="'/club/form/'">
  78. <el-button type="primary" size="small">编辑</el-button>
  79. </router-link>
  80. <router-link :to="{path:'/club/operateList',query:{clubID:row.clubID,userID:row.userID}}">
  81. <el-button type="primary" size="small">查看运营人员</el-button>
  82. </router-link>
  83. <el-button type="primary" size="small" @click="handleEdit(row)">添加运营人员</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <pagination
  88. v-show="total>0"
  89. :total="total"
  90. :page-size="10"
  91. :page.sync="listQuery.page"
  92. :limit.sync="listQuery.limit"
  93. @pagination="fetchData"
  94. />
  95. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
  96. <el-form ref="dataForm" :rules="rules" :model="addPeople" label-position="left" label-width="70px" style="width: 400px; margin-left:24%;">
  97. <el-form-item label="姓名" prop="linkName">
  98. <el-input v-model="addPeople.linkName" maxlength="11" />
  99. </el-form-item>
  100. <el-form-item label="手机号" prop="mobile">
  101. <el-input v-model="addPeople.mobile" maxlength="11" />
  102. </el-form-item>
  103. </el-form>
  104. <div slot="footer" class="dialog-footer">
  105. <el-button @click="dialogFormVisible = false">取消</el-button>
  106. <el-button type="primary" @click="handleCreateOperator()">保存</el-button>
  107. <el-button type="primary" @click="handlePreservOperator()">保存生成邀请码</el-button>
  108. </div>
  109. </el-dialog>
  110. <el-dialog title="系统提示" :visible.sync="dialogVisible" width="15%">
  111. <span>{{ dialogVisibleText }}</span>
  112. <span slot="footer" class="dialog-footer">
  113. <el-button @click="dialogVisible = false">取 消</el-button>
  114. <el-button type="primary" @click="handleConfim()">确 定</el-button>
  115. </span>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import {
  121. getClubList,
  122. createOperator,
  123. preservOperator,
  124. updateStatus,
  125. queryClubList
  126. } from '@/api/club'
  127. import Pagination from '@/components/Pagination'
  128. export default {
  129. components: { Pagination },
  130. filters: {
  131. statusFilter(status) {
  132. const statusMap = {
  133. 1: 'success',
  134. 0: 'gray'
  135. }
  136. return statusMap[status]
  137. }
  138. },
  139. data() {
  140. return {
  141. list: null,
  142. listLoading: true,
  143. total: 0,
  144. listQuery: {
  145. page: 1,
  146. limit: 10,
  147. importance: undefined,
  148. title: undefined,
  149. type: undefined,
  150. sort: '+id'
  151. },
  152. searchForm: {
  153. name: '',
  154. linkName: '',
  155. mobile: '',
  156. clubStatus: ''
  157. },
  158. startTime: '',
  159. endTime: '',
  160. addPeople: {
  161. linkName: '',
  162. mobile: ''
  163. },
  164. updateTemp: {},
  165. updateTatusType: '',
  166. dialogVisible: false,
  167. dialogVisibleText: '',
  168. dialogFormVisible: false,
  169. dialogStatus: '',
  170. textMap: {
  171. update: '添加运营人员',
  172. create: 'Create',
  173. titleText: '系统提示'
  174. },
  175. rules: {
  176. classifyName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
  177. telephone: [{ required: true, message: '手机号码不能为空', trigger: 'blur' }]
  178. }
  179. }
  180. },
  181. created() {
  182. this.fetchData()
  183. },
  184. methods: {
  185. fetchData() {
  186. this.listLoading = true
  187. const params = { userOrganizeID: this.organizeID, index: 1, pageSize: 10 }
  188. getClubList(params).then(response => {
  189. if (response.code === '1') {
  190. const data = response.data
  191. this.list = data.results
  192. this.listLoading = false
  193. this.total = data.totalRecord
  194. } else {
  195. this.$message.error(response.msg)
  196. }
  197. }).catch(() => {
  198. // 封装静态数据
  199. })
  200. this.listLoading = false
  201. },
  202. handleEdit(row) { // 添加运营
  203. console.log(row)
  204. this.dialogStatus = 'update'
  205. this.dialogFormVisible = true
  206. this.addPeople = Object.assign({}, { clubID: row.clubID, userID: row.userID })
  207. this.$nextTick(() => {
  208. this.$refs['dataForm'].clearValidate()
  209. })
  210. },
  211. handleCreateOperator() { // 保存
  212. this.$refs['dataForm'].validate((valid) => {
  213. if (valid) {
  214. const Formobj = { userOrganizeID: this.organizeID, configFlag: 1 }
  215. const params = Object.assign(Formobj, this.addPeople)
  216. createOperator(params).then(response => {
  217. this.dialogFormVisible = false
  218. this.$message({
  219. message: '保存成功',
  220. type: 'success',
  221. center: true
  222. })
  223. })
  224. }
  225. })
  226. },
  227. handlePreservOperator() { // 保存并生成邀请码
  228. this.$refs['dataForm'].validate((valid) => {
  229. if (valid) {
  230. const Formobj = { userOrganizeID: this.organizeID, configFlag: 1 }
  231. const params = Object.assign(Formobj, this.addPeople)
  232. preservOperator(params).then(response => {
  233. this.dialogFormVisible = false
  234. this.$message({
  235. message: '生成邀请码成功',
  236. type: 'success',
  237. center: true
  238. })
  239. })
  240. }
  241. })
  242. },
  243. handOnline(row) {
  244. this.updateTemp = Object.assign({}, { clubID: row.clubID, userID: row.userID, clubStatus: row.clubStatus, userOrganizeID: this.organizeID })
  245. this.dialogVisible = true
  246. this.dialogVisibleText = '确定上线该会所吗?'
  247. this.updateTatusType = 'online'
  248. },
  249. handOffline(row) {
  250. console.log(row.id)
  251. this.updateTemp = Object.assign({}, { clubID: row.clubID, userID: row.userID, clubStatus: row.clubStatus, userOrganizeID: this.organizeID })
  252. this.dialogVisible = true
  253. this.dialogVisibleText = '确定下线该会所吗?'
  254. this.updateTatusType = 'offline'
  255. },
  256. handleConfim() {
  257. if (this.updateTatusType === 'online') {
  258. const params = Object.assign({}, this.updateTemp)
  259. updateStatus(params).then(response => {
  260. if (response.code === '1') {
  261. this.$message({ message: '上线会所成功', type: 'success', center: true })
  262. this.list = []
  263. this.fetchData()
  264. } else {
  265. this.$message.error(response.msg)
  266. }
  267. this.dialogVisible = false
  268. })
  269. } else {
  270. const params = Object.assign({}, this.updateTemp)
  271. updateStatus(params).then(response => {
  272. if (response.code === '1') {
  273. this.$message({ message: '下线会所成功', type: 'success', center: true })
  274. this.list = []
  275. this.fetchData()
  276. } else {
  277. this.$message.error(response.msg)
  278. }
  279. this.dialogVisible = false
  280. })
  281. }
  282. },
  283. onSubmit() {
  284. this.$refs['searchForm'].validate((valid) => {
  285. if (valid) {
  286. const Fromobj = { userOrganizeID: this.organizeID, startTime: this.startTime, endTime: this.endTime, index: 1, pageSize: 10 }
  287. const params = Object.assign(Fromobj, this.searchForm)
  288. console.log(params)
  289. getClubList(params).then(response => {
  290. if (response.code === '1') {
  291. const data = response.data
  292. this.list = data.results
  293. this.listLoading = false
  294. this.total = data.totalRecord
  295. } else {
  296. this.$message.error(response.msg)
  297. }
  298. }).catch(() => {
  299. // 封装静态数据
  300. })
  301. }
  302. })
  303. }
  304. }
  305. }
  306. </script>