lotteryTicket_statistics.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div>
  3. <div class="integral_statistics_box">
  4. <el-row :gutter="10" style="margin-bottom: 20px;margin-right:8px;">
  5. <el-col :span="5">
  6. <el-date-picker
  7. v-model="formData.month"
  8. type="month"
  9. placeholder="请选择月份"
  10. value-format="yyyy-MM"
  11. ></el-date-picker
  12. ></el-col>
  13. <el-col :span="5" style="position: relative;">
  14. <deptData deptStyle="padding-left:10px;" v-if="toPdept1 && toPdept1!=0" :refsName="$refs.dept1" :toPdept="toPdept1"></deptData>
  15. <el-cascader
  16. v-model="dept_name"
  17. :options="dept_tree"
  18. @change="dept1_null"
  19. :props="{ label: 'name', value: 'id'}"
  20. ref="dept1"
  21. filterable
  22. change-on-select
  23. placeholder="请选择部门"
  24. clearable
  25. >
  26. <template slot-scope="{ node, data }">
  27. <span>
  28. <WWOpenData type="departmentName" :openid="data.name"></WWOpenData>
  29. </span>
  30. <!-- <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span> -->
  31. </template>
  32. </el-cascader>
  33. </el-col>
  34. <el-col :span="5" class="search">
  35. <el-input
  36. v-model="formData.keywords"
  37. placeholder="输入同事姓名"
  38. @keyup.enter.native="get_all_integral"
  39. >
  40. <el-button
  41. slot="append"
  42. @click="get_all_integral"
  43. icon="el-icon-search"
  44. ></el-button>
  45. </el-input>
  46. </el-col>
  47. </el-row>
  48. <el-table
  49. :data="all_integral_list"
  50. style="width: 100%"
  51. v-loading="loading"
  52. >
  53. <el-table-column prop="employee_name" label="姓名" align="left">
  54. <template slot-scope="scope">
  55. <span class="fl">
  56. <userImage
  57. :id="scope.row.id"
  58. width="50px"
  59. height="50px"
  60. :user_name="scope.row.name"
  61. ></userImage>
  62. </span>
  63. <span
  64. style="margin-left: 20px; line-height: 50px; display: inline-block"
  65. ><WWOpenData type="userName" :openid="scope.row.name"></WWOpenData></span
  66. >
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="performance" label="部门" align="left">
  70. <template slot-scope="scope">
  71. <span v-for="(item,index) in scope.row.depart_name" :key="index"><WWOpenData type="departmentName" :openid="item"></WWOpenData><span v-if="(scope.row.depart_name.length-index)>1">,</span></span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="a" label="奖票数量" align="left">
  75. <template slot-scope="scope">
  76. <span>{{ scope.row.ticketNumber }}</span>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <center style="padding: 20px 0;">
  81. <el-pagination
  82. background
  83. @size-change="handleSizeChange1"
  84. @current-change="handleCurrentChange"
  85. :current-page="formData.page"
  86. :page-sizes="[10, 20, 50, 100]"
  87. layout="total, sizes, prev, pager, next"
  88. :page-size="pageLimit1"
  89. :total="total"
  90. >
  91. </el-pagination>
  92. </center>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. export default {
  98. data() {
  99. return {
  100. loading: false,
  101. all_integral_list: null,
  102. formData: {
  103. month: this.$moment().format("YYYY-MM"),
  104. keywords: "",
  105. dept_id: "",
  106. page: 1,
  107. page_size: 10
  108. },
  109. total: 0,
  110. dept_tree: [],
  111. dept_name: [],
  112. pageLimit1: 10,
  113. toPdept1:0,
  114. };
  115. },
  116. components: {},
  117. watch: {
  118. "formData.month"(val, old_val) {
  119. this.formData.page = 1;
  120. this.get_all_integral();
  121. },
  122. "formData.dept_id"(val, old_val) {
  123. if (!val) {
  124. this.formData.dept_id = 0;
  125. }
  126. this.formData.page = 1;
  127. this.get_all_integral();
  128. }
  129. },
  130. mounted() {
  131. if (localStorage.getItem("dept_tree")) {
  132. this.dept_tree = this.getTreeData(
  133. JSON.parse(localStorage.getItem("dept_tree"))
  134. );
  135. }
  136. this.get_all_integral();
  137. },
  138. methods: {
  139. //分页
  140. handleSizeChange1(val) {
  141. this.pageLimit1 = val;
  142. this.formData.page_size = this.pageLimit1;
  143. this.get_all_integral();
  144. },
  145. handleCurrentChange(val) {
  146. this.formData.page = val;
  147. this.get_all_integral();
  148. },
  149. //请求数据
  150. get_all_integral() {
  151. let self = this;
  152. self.loading = true;
  153. self
  154. .$http("get", "/api/integral/statistics/ticket", self.formData)
  155. .then(res => {
  156. if (res.data.code == 1) {
  157. self.all_integral_list = res.data.data.list;
  158. self.total = res.data.data.total;
  159. } else {
  160. self.$message.error(res.data.data.msg);
  161. }
  162. })
  163. .finally(() => {
  164. self.loading = false;
  165. });
  166. },
  167. dept1_null(val) {
  168. this.toPdept1 = val[val.length-1]
  169. //部门
  170. if (val.length == 0) {
  171. this.formData.dept_id = 0;
  172. } else {
  173. this.formData.dept_id = this.dept_name[this.dept_name.length - 1];
  174. }
  175. this.$nextTick(() => {
  176. this.$refs.dept1.dropDownVisible = false;
  177. });
  178. },
  179. // 递归判断列表,把最后的children设为undefined
  180. getTreeData(data) {
  181. for (var i = 0; i < data.length; i++) {
  182. if (data[i].children.length < 1) {
  183. // children若为空数组,则将children设为undefined
  184. data[i].children = undefined;
  185. } else {
  186. // children若不为空数组,则继续 递归调用 本方法
  187. this.getTreeData(data[i].children);
  188. }
  189. }
  190. return data;
  191. }
  192. }
  193. };
  194. </script>
  195. <style scoped>
  196. .el-date-editor.el-input {
  197. width: auto;
  198. }
  199. .date-picker-width {
  200. width: 145px !important;
  201. }
  202. .search /deep/ .el-input-group__append:active {
  203. background: #26a2ff;
  204. }
  205. .search /deep/ .el-input-group__append:active .el-icon-search {
  206. color: #fff;
  207. }
  208. </style>
  209. <style lang="scss" scoped>
  210. .integral_statistics_box {
  211. background-color: #ffffff;
  212. padding: 20px;
  213. min-height: calc(100vh - 160px);
  214. }
  215. </style>