list.vue 11 KB

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