list.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <page-header-wrapper>
  3. <a-card :bordered="false">
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="5" :sm="24">
  8. <a-form-item>
  9. <a-input v-model="queryParam.id" placeholder="名单姓名/家长手机号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="5" :sm="24">
  13. <a-form-item>
  14. <a-select v-model="queryParam.status" placeholder="一级来源" default-value="0">
  15. <a-select-option value="0">全部</a-select-option>
  16. <a-select-option value="1">关闭</a-select-option>
  17. <a-select-option value="2">运行中</a-select-option>
  18. </a-select>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="5" :sm="24">
  22. <a-form-item>
  23. <a-select v-model="queryParam.status" placeholder="跟进状态" default-value="0">
  24. <a-select-option value="0">全部</a-select-option>
  25. <a-select-option value="1">关闭</a-select-option>
  26. <a-select-option value="2">运行中</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="5" :sm="24">
  31. <a-form-item>
  32. <a-input v-model="queryParam.id" placeholder="请选择采单人姓名"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="!advanced && 4 || 24" :sm="24">
  36. <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
  37. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  38. <a-button style="margin-left: 8px" @click="() => this.queryParam = {}">重置</a-button>
  39. </span>
  40. </a-col>
  41. </a-row>
  42. </a-form>
  43. </div>
  44. <a-row style="margin-bottom:15px">
  45. 已选<a-button size="small" type="link">{{ selectedRows.length }}</a-button>条数据 <a-button size="small" @click="handleAssign">分配</a-button> <a-button size="small" @click="handleGain">捞取</a-button>
  46. </a-row>
  47. <s-table
  48. ref="table"
  49. size="default"
  50. :rowKey="record => record.id"
  51. :columns="columns"
  52. :data="loadData"
  53. :alert="false"
  54. :rowSelection="rowSelection"
  55. showPagination="auto">
  56. <span slot="serial" slot-scope="text, record, index">
  57. {{ index + 1 }}
  58. </span>
  59. <span slot="status" slot-scope="text">
  60. <a-badge :status="text | statusTypeFilter" :text="text | statusFilter" />
  61. </span>
  62. <span slot="description" slot-scope="text">
  63. <ellipsis :length="4" tooltip>{{ text }}</ellipsis>
  64. </span>
  65. </s-table>
  66. <!-- 分配 -->
  67. <assign-form
  68. ref="createModal"
  69. :visible="visible"
  70. :loading="confirmLoading"
  71. :model="mdl"
  72. :length="selectedRows.length"
  73. @cancel="handleCancel"
  74. @ok="handleOk"
  75. ></assign-form>
  76. <!-- 分配 -->
  77. <gain-form
  78. ref="gainModal"
  79. :visible="gainVisible"
  80. :length="selectedRows.length"
  81. :loading="confirmLoading"
  82. :model="mdl"
  83. @cancel="handleGainCancel"
  84. @ok="handleGainOk"
  85. ></gain-form>
  86. </a-card>
  87. </page-header-wrapper>
  88. </template>
  89. <script>
  90. import moment from 'moment'
  91. import { STable, Ellipsis } from '@/components';
  92. import { getRoleList, getServiceList } from '@/api/manage'
  93. import AssignForm from '../modules/AssignForm'
  94. import GainForm from '../modules/GainForm'
  95. const columns = [
  96. {
  97. title: '#',
  98. scopedSlots: { customRender: 'serial' }
  99. },
  100. {
  101. title: '规则编号',
  102. dataIndex: 'no'
  103. },
  104. {
  105. title: '描述',
  106. dataIndex: 'description',
  107. scopedSlots: { customRender: 'description' }
  108. },
  109. {
  110. title: '服务调用次数',
  111. dataIndex: 'callNo',
  112. sorter: true,
  113. needTotal: true,
  114. customRender: (text) => text + ' 次'
  115. },
  116. {
  117. title: '状态',
  118. dataIndex: 'status',
  119. scopedSlots: { customRender: 'status' }
  120. },
  121. {
  122. title: '更新时间',
  123. dataIndex: 'updatedAt',
  124. sorter: true
  125. }
  126. ]
  127. const statusMap = {
  128. 0: {
  129. status: 'default',
  130. text: '关闭'
  131. },
  132. 1: {
  133. status: 'processing',
  134. text: '运行中'
  135. },
  136. 2: {
  137. status: 'success',
  138. text: '已上线'
  139. },
  140. 3: {
  141. status: 'error',
  142. text: '异常'
  143. }
  144. }
  145. export default {
  146. name: 'SeasList',
  147. components: {
  148. STable,
  149. Ellipsis,
  150. AssignForm,
  151. GainForm
  152. },
  153. data() {
  154. this.columns = columns
  155. return {
  156. // create model
  157. visible: false,
  158. gainVisible: false,
  159. confirmLoading: false,
  160. mdl: null,
  161. // 高级搜索 展开/关闭
  162. advanced: false,
  163. // 查询参数
  164. queryParam: {},
  165. loadData: parameter => {
  166. const requestParameters = Object.assign({}, parameter, this.queryParam)
  167. console.log('loadData request parameters:', requestParameters)
  168. return getServiceList(requestParameters)
  169. .then(res => {
  170. return res.result
  171. })
  172. },
  173. selectedRowKeys: [],
  174. selectedRows: []
  175. }
  176. },
  177. filters: {
  178. statusFilter (type) {
  179. return statusMap[type].text
  180. },
  181. statusTypeFilter (type) {
  182. return statusMap[type].status
  183. }
  184. },
  185. created() {
  186. },
  187. computed: {
  188. rowSelection () {
  189. return {
  190. selectedRowKeys: this.selectedRowKeys,
  191. onChange: this.onSelectChange
  192. }
  193. }
  194. },
  195. mounted() {
  196. },
  197. methods: {
  198. toggleAdvanced () {
  199. this.advanced = !this.advanced
  200. },
  201. handleEdit (record) {
  202. this.visible = true;
  203. this.mdl = { ...record }
  204. },
  205. handleSub (record) {
  206. if (record.status !== 0) {
  207. this.$message.info(`${record.no} 订阅成功`)
  208. } else {
  209. this.$message.error(`${record.no} 订阅失败,规则已关闭`)
  210. }
  211. },
  212. onSelectChange (selectedRowKeys, selectedRows) {
  213. console.log(selectedRowKeys);
  214. console.log(selectedRows);
  215. this.selectedRowKeys = selectedRowKeys
  216. this.selectedRows = selectedRows
  217. },
  218. // 分配
  219. handleAssign() {
  220. if(this.selectedRows.length <= 0) {
  221. this.$message.error('请至少选择一个学员');
  222. return;
  223. }
  224. this.visible = true;
  225. },
  226. // 捞取
  227. handleGain() {
  228. if(this.selectedRows.length <= 0) {
  229. this.$message.error('请至少选择一个学员');
  230. return;
  231. }
  232. this.gainVisible = true
  233. },
  234. beforeOpen() {
  235. },
  236. handleOk () {
  237. const form = this.$refs.createModal.form;
  238. const ruleForm = this.$refs.createModal.$refs.ruleForm
  239. this.confirmLoading = true
  240. ruleForm.validate(valid => {
  241. if (valid) {
  242. if (form.id > 0) {
  243. // 修改 e.g.
  244. new Promise((resolve, reject) => {
  245. setTimeout(() => {
  246. resolve()
  247. console.log(form)
  248. }, 1000)
  249. }).then(res => {
  250. this.visible = false
  251. this.confirmLoading = false
  252. // 重置表单数据
  253. ruleForm.resetFields()
  254. // 刷新表格
  255. this.$refs.table.refresh()
  256. this.$message.info('修改成功')
  257. })
  258. } else {
  259. // 新增
  260. new Promise((resolve, reject) => {
  261. setTimeout(() => {
  262. resolve()
  263. console.log(form)
  264. }, 1000)
  265. }).then(res => {
  266. this.visible = false
  267. this.confirmLoading = false
  268. // 重置表单数据
  269. ruleForm.resetFields()
  270. // 刷新表格
  271. this.$refs.table.refresh()
  272. this.$message.info('新增成功')
  273. })
  274. }
  275. } else {
  276. this.confirmLoading = false
  277. }
  278. })
  279. },
  280. handleGainOk() {
  281. this.gainVisible = false;
  282. this.$refs.table.refresh();
  283. this.$message.info('修改成功');
  284. },
  285. handleCancel () {
  286. this.visible = false
  287. const ruleForm = this.$refs.createModal.$refs.ruleForm
  288. ruleForm.resetFields() // 清理表单数据(可不做)
  289. },
  290. handleGainCancel() {
  291. this.gainVisible = false;
  292. }
  293. }
  294. }
  295. </script>
  296. <style>
  297. </style>