index.vue 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="subPage">
  3. <div class="title">
  4. 签到列表
  5. </div>
  6. <div class="head-div">
  7. <span class="time-title">时间选择:</span>
  8. <el-select v-model="valueTime" placeholder="请选择">
  9. <el-option
  10. v-for="item in optionsTime"
  11. :key="item.valueTime"
  12. :label="item.label"
  13. :value="item.valueTime">
  14. </el-option>
  15. </el-select>
  16. <!-- 案场选择 -->
  17. <span class="case-title">案场:</span>
  18. <el-select v-model="valueCase" placeholder="请选择" @change="handelSignin">
  19. <el-option
  20. key=""
  21. label="所有案场"
  22. value="">
  23. </el-option>
  24. <el-option
  25. v-for="item in optionsCase"
  26. :key="item.valueCase"
  27. :label="item.label"
  28. :value="item.valueCase">
  29. </el-option>
  30. </el-select>
  31. </div>
  32. <div class="button-div">
  33. <el-button type="success" icon="el-icon-search" style="float: right;" @click="excelSignin">导出excel</el-button>
  34. <el-button type="warning" icon="el-icon-search" style="float: right;" @click="reset">重置</el-button>
  35. <el-button type="primary" icon="el-icon-search" style="float: right; margin-right: -10px;" @click="getList">搜索</el-button>
  36. </div>
  37. <!-- 表格 -->
  38. <div class="content">
  39. <el-table
  40. :data="tableData"
  41. border
  42. style="width: 100%">
  43. <el-table-column
  44. prop="CaseName"
  45. label="案场"
  46. width="180">
  47. </el-table-column>
  48. <el-table-column
  49. prop="CreateDate"
  50. label="签到时间"
  51. width="250">
  52. <template slot-scope="scope">
  53. <span>{{FormatDate(scope.row.CreateDate)}}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. prop="CustomerName"
  58. label="微信昵称">
  59. </el-table-column>
  60. <el-table-column
  61. prop="Name"
  62. label="客户姓名">
  63. </el-table-column>
  64. <el-table-column
  65. prop="address"
  66. label="客户类型">
  67. <template slot-scope="scope">
  68. <span>{{scope.row.UserId === '' ? '前台用户' : '后台用户'}}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column
  72. prop="Phone"
  73. label="手机号">
  74. </el-table-column>
  75. </el-table>
  76. </div>
  77. <!-- 分页 -->
  78. <div class="foot">
  79. <el-pagination
  80. @size-change="handleSizeChange"
  81. @current-change="handleCurrentChange"
  82. :current-page.sync="postData.page"
  83. :page-size="100"
  84. layout="prev, pager, next, jumper"
  85. :total="total">
  86. </el-pagination>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import { mapState } from 'vuex'
  92. export default {
  93. name: '',
  94. data () {
  95. return {
  96. msg: '签到管理',
  97. currentPage: 1,
  98. postData: { // 表格搜索条件 //caseid: '', // 案场id
  99. page: 1, // 当前页码
  100. pageSize: 10, // 请求数据量
  101. },
  102. total: 0, // 总数
  103. // 数据体
  104. // {date: '2016-05-02',name: '王小虎',address: '上海市普陀区金沙江路 1518 弄'}
  105. tableData: [],
  106. // 时间数据
  107. optionsTime: [{
  108. valueTime: '-1',
  109. label: '全部'
  110. }, {
  111. valueTime: '0',
  112. label: '今天'
  113. }, {
  114. valueTime: '1',
  115. label: '本周'
  116. }, {
  117. valueTime: '2',
  118. label: '本月'
  119. }, {
  120. valueTime: '3',
  121. label: '今年'
  122. }],
  123. valueTime: '0',
  124. // 案场数据
  125. // {valueCase: '1',label: '案场1'}
  126. optionsCase: [], // 调用computed计算属性
  127. tempoptionsCase: [], // 临时的存储案场数据
  128. valueCase: ''
  129. }
  130. },
  131. mounted () {
  132. // 获取案场列表
  133. this.getCase()
  134. },
  135. methods: {
  136. handleSizeChange (val) {
  137. console.log(`每页 ${val} 条`)
  138. },
  139. handleCurrentChange (val) {
  140. console.log(`当前页: ${val}`)
  141. this.$data.postData.page = val
  142. this.getList()
  143. },
  144. getList () { // 获取数据列表
  145. this.$ajax(this.$api.caseManager.getSignin.url, {
  146. method: this.$api.caseManager.getSignin.method,
  147. queryData: { ...this.postData, org: this.$data.valueCase, selectType: this.$data.valueTime }
  148. }).then(res => {
  149. this.tableData = res.list
  150. this.postData.page = res.page
  151. this.total = res.pagenum
  152. })
  153. },
  154. getCase () { // 获取案场数据列表
  155. this.$ajax(this.$api.caseManager.getCaseList.url, {
  156. method: this.$api.caseManager.getCaseList.method,
  157. queryData: { ...this.postData, caseid: this.CaseId }
  158. }).then(res => {
  159. this.tempoptionsCase = res.list
  160. this.postData.page = res.page
  161. this.total = res.pagenum
  162. // 调用一次,计算属性
  163. this.optionsCase = this.CaseCompted
  164. })
  165. },
  166. handelSignin () { // 查询签到记录
  167. this.getList()
  168. },
  169. reset () { // 重置按钮
  170. this.$data.valueTime = '0'
  171. this.$data.total = ''
  172. this.$data.tableData = []
  173. this.$data.postData.page = 1
  174. this.$data.postData.pageSize = 10
  175. this.$data.valueCase = ''
  176. },
  177. FormatDate (date) {
  178. return this.toolClass.dateFormat(date, 'yyyy-MM-dd hh:mm:ss')
  179. },
  180. excelSignin () { // 导出Excel
  181. window.open(`${this.toolClass.ReplaceOrg(this.$api.caseManager.getExcelSignin.url)}?token=${localStorage.getItem('JWT')}&selectType=${this.$data.valueTime}&caseid=${this.$data.valueCase}`, '_blank')
  182. }
  183. },
  184. computed: {
  185. ...mapState({
  186. cases: x => x.app.cases.list,
  187. defaultCaseId: x => x.app.cases.default
  188. }),
  189. CaseId: {
  190. get () {
  191. return this.postData.caseid || this.defaultCaseId
  192. },
  193. set (val) {
  194. this.postData.caseid = val
  195. }
  196. },
  197. CaseCompted: {
  198. get () { // get方法
  199. let data = []
  200. console.log('数据大小')
  201. console.log(this.$data.tempoptionsCase)
  202. var cases = this.$data.tempoptionsCase
  203. for (let i = 0; i < cases.length; i++) {
  204. let obj = []
  205. obj.valueCase = cases[i].CaseId
  206. obj.label = cases[i].CaseName
  207. console.log('编号:' + obj.valueCase + '名称:' + obj.label)
  208. data.push(obj)
  209. }
  210. return data
  211. }
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. @import "page.scss";
  218. </style>