PointAutoSetting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <div style=" background-color: #fff;">
  3. <el-row :gutter="15" style="border:1px solid #eee;">
  4. <el-col v-show="false" :span="24" style="margin-bottom:0; border-bottom:1px solid #eee;">
  5. <div style="margin-bottom:0; padding:15px;" class="inline-block-btn-list">
  6. <div class="gap-right-8" style="display:inline-block; width:100%; margin-bottom:0;">
  7. <el-input
  8. placeholder="输入关键词查找"
  9. ref="search-bar"
  10. v-model="filter.keywords"
  11. class="input-with-select"
  12. @keyup.enter.native="onFilterChanged"
  13. >
  14. <el-button slot="append" icon="el-icon-search" @click="onFilterChanged"></el-button>
  15. </el-input>
  16. </div>
  17. </div>
  18. </el-col>
  19. <el-col :span="4" style="margin-bottom:0;">
  20. <div style="padding:15px; padding-left:0; padding-right:0;">
  21. <el-scrollbar
  22. wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
  23. :native="false"
  24. style="height: 450px;"
  25. >
  26. <a
  27. @click="handleNodeClick({value:0})"
  28. v-show="profile.manager_type > 2"
  29. :class="{on:filter.dept_id.length == 0}"
  30. style="display: block; padding:7px; font-size:14px;"
  31. >所有部门</a>
  32. <el-tree
  33. ref="dept_tree_com"
  34. highlight-current
  35. :default-expand-all="true"
  36. :expand-on-click-node="false"
  37. :data="deptTree"
  38. @node-click="handleNodeClick"
  39. ></el-tree>
  40. </el-scrollbar>
  41. </div>
  42. </el-col>
  43. <el-col :span="6" style="border-left:1px solid #eee; margin-bottom:0; padding-right:0;">
  44. <div style="padding:15px; padding-right:0;">
  45. <div class="check-item-box" style="height: 450px;">
  46. <div style="padding-right:15px;">
  47. <el-scrollbar
  48. wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
  49. :native="false"
  50. style="height: 450px;"
  51. >
  52. <el-table
  53. v-loading="loading"
  54. ref="multipleTable"
  55. :data="tableData"
  56. :border="false"
  57. tooltip-effect="dark"
  58. @row-click="rowClick"
  59. @selection-change="handleSelectionChange"
  60. @select-all="select_all"
  61. :row-class-name="is_checked"
  62. style="width: 100%"
  63. >
  64. <el-table-column prop="name" label="选择人员">
  65. <template slot-scope="scope">
  66. <div
  67. :class="{rank_head:true, checked:checkid==scope.row.id}"
  68. style="cursor: pointer;"
  69. >
  70. <img
  71. v-if="scope.row.img_url != null"
  72. v-bind:src="scope.row.img_url"
  73. width="42px"
  74. height="42px"
  75. >
  76. <img
  77. v-if="scope.row.img_url == null"
  78. src="static/images/head_default.png"
  79. width="42px"
  80. height="42px"
  81. >
  82. {{scope.row.name}}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="已设置" width="100">
  87. <template slot-scope="scope">
  88. <div
  89. style="cursor: pointer; height:50px;"
  90. :class="{rank_head:true, checked:checkid==scope.row.id}"
  91. >
  92. <span
  93. v-if="typeof(itemCount[scope.row.id.toString()]) != 'undefined'"
  94. >{{itemCount[scope.row.id]}}个记录</span>
  95. <span v-if="typeof(itemCount[scope.row.id.toString()]) == 'undefined'">暂无</span>
  96. </div>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. </el-scrollbar>
  101. </div>
  102. </div>
  103. </div>
  104. </el-col>
  105. <el-col :span="14" style="border-left:1px solid #eee; margin-bottom:0; padding-right:0;">
  106. <div style="padding:15px; padding-right:0;">
  107. <div style="padding-right:15px; height: 450px;">
  108. <PointAutoList ref="pointautolistcom"></PointAutoList>
  109. </div>
  110. </div>
  111. </el-col>
  112. </el-row>
  113. </div>
  114. </template>
  115. <script>
  116. import PointAutoList from "./PointAutoList";
  117. export default {
  118. components: { PointAutoList },
  119. data() {
  120. return {
  121. loading: false,
  122. profile: this.$store.getters.user_info,
  123. accessEnabled: false,
  124. dialogTableVisible: false,
  125. filter: {
  126. dept_id: [],
  127. status: 1,
  128. keywords: ""
  129. },
  130. checkid: 0,
  131. totalCount: 0,
  132. pageLimit: 3000,
  133. currentPage: 1,
  134. tableData: null,
  135. multipleSelection: [],
  136. multipleSelectionId: [],
  137. multipleSelectionJson: {},
  138. pageSelectedId: [],
  139. dialogExcelVisible: false,
  140. deptTree: [],
  141. creatorId: "",
  142. department_list: [],
  143. itemCount: {}
  144. };
  145. },
  146. methods: {
  147. is_checked(row) {
  148. if (this.checkid == row.id) {
  149. return "td_checked";
  150. } else {
  151. return "";
  152. }
  153. },
  154. clearEmployee(column, event) {
  155. let self = this;
  156. if (column.columnKey == "clear") {
  157. for (let i in this.tableData) {
  158. self.$refs["multipleTable"].toggleRowSelection(
  159. self.tableData[i],
  160. false
  161. );
  162. }
  163. this.multipleSelectionId = [];
  164. this.multipleSelectionJson = {};
  165. this.multipleSelection = [];
  166. this.pageSelectedId = [];
  167. }
  168. },
  169. removeEmployee(id) {
  170. let multipleSelectionId = [];
  171. let multipleSelectionJson = {};
  172. let multipleSelection = [];
  173. let pageSelectedId = [];
  174. for (let i in this.tableData) {
  175. if (this.tableData[i].id == id) {
  176. this.$refs["multipleTable"].toggleRowSelection(
  177. this.tableData[i],
  178. false
  179. );
  180. }
  181. }
  182. for (let i in this.multipleSelection) {
  183. if (this.multipleSelection[i].id != id) {
  184. multipleSelection.push(this.multipleSelection[i]);
  185. multipleSelectionJson[
  186. this.multipleSelection[i].id
  187. ] = this.multipleSelection[i];
  188. multipleSelectionId.push(this.multipleSelection[i].id);
  189. }
  190. }
  191. this.multipleSelectionId = multipleSelectionId;
  192. this.multipleSelectionJson = multipleSelectionJson;
  193. this.multipleSelection = multipleSelection;
  194. },
  195. handleNodeClick(data) {
  196. if (data.value == 0) {
  197. this.loadBaseData();
  198. this.filter.dept_id = [];
  199. } else {
  200. this.filter.dept_id = [data.value];
  201. }
  202. this.onFilterChanged();
  203. },
  204. handleSizeChange(val) {
  205. this.pageLimit = val;
  206. this.onFilterChanged();
  207. },
  208. onFilterChanged: function() {
  209. this.currentPage = 1;
  210. this.loadEmployeeList();
  211. },
  212. toggleSelection: function(rows) {
  213. if (rows) {
  214. rows.forEach(row => {
  215. this.$refs.multipleTable.toggleRowSelection(row);
  216. });
  217. } else {
  218. this.$refs.multipleTable.clearSelection();
  219. }
  220. },
  221. select_all(all) {
  222. let ids = [];
  223. for (let i in all) {
  224. ids.push(all[i].id);
  225. }
  226. },
  227. handleSelectionChange: function(val) {},
  228. rowClick(row, event, column) {
  229. if (row.id == this.checkid) {
  230. this.checkid = 0;
  231. } else {
  232. this.checkid = row.id;
  233. }
  234. this.$refs["pointautolistcom"].filter.employee_id = this.checkid;
  235. this.$refs["pointautolistcom"].onFilterChanged();
  236. this.$emit("check", row);
  237. },
  238. isSelectable: function(row, index) {
  239. return true;
  240. },
  241. toSexName: function(row, column, cellValue) {
  242. return cellValue == "1" ? "女" : "男";
  243. },
  244. dateFormatter: function(row, column, cellValue) {
  245. return this.$moment(cellValue * 1000).format("YYYY年MM月DD日");
  246. },
  247. //获取基本数据
  248. loadBaseData: function() {
  249. var self = this;
  250. this.$http('get',"/integral.php/ajax_request_common/prepare_integral_options",{
  251. id: this.profile.id,
  252. category_tree: 1,
  253. dept_tree: 1
  254. })
  255. .then(function(response) {
  256. if (response.status == 200) {
  257. var jsonData = response.data;
  258. try {
  259. self.deptTree = jsonData.dept_tree;
  260. self.creatorId = jsonData.creator_id;
  261. if (self.profile.manager_type < 2) {
  262. self.filter.dept_id = [self.deptTree[0].value];
  263. self.loadEmployeeList();
  264. }
  265. } catch (err) {
  266. console.log(err);
  267. }
  268. }
  269. })
  270. .catch(function(error) {
  271. console.log(error);
  272. });
  273. },
  274. //获取基本数据
  275. loadDataCount: function() {
  276. var self = this;
  277. this.$http('get',"/integral.php/point_auto_setting/get_count_by_employee")
  278. .then(function(response) {
  279. if (response.status == 200) {
  280. var jsonData = response.data;
  281. try {
  282. self.itemCount = jsonData.data;
  283. } catch (err) {
  284. console.log(err);
  285. }
  286. }
  287. })
  288. .catch(function(error) {
  289. console.log(error);
  290. });
  291. },
  292. //获取员工列表
  293. loadEmployeeList: function() {
  294. var self = this;
  295. self.loading = true;
  296. let params = {
  297. site_id: this.$store.getters.site_id,
  298. page: this.currentPage,
  299. interval: this.pageLimit
  300. };
  301. for (let item in this.filter) {
  302. let value = this.filter[item];
  303. if (item == "dept_id") {
  304. if (!value || value.length == 0) {
  305. continue;
  306. }
  307. params[item] = value[value.length - 1];
  308. } else {
  309. let valueStr = value.toString();
  310. if (valueStr && valueStr.length > 0) {
  311. params[item] = valueStr;
  312. }
  313. }
  314. }
  315. this.$http('get',"/integral.php/ajax_request_common/get_employee_list",params)
  316. .then(function(response) {
  317. if (response.status == 200) {
  318. self.loading = false;
  319. var jsonData = response.data;
  320. try {
  321. self.department_list = jsonData.filter_list.department;
  322. self.totalCount = jsonData.total_count;
  323. self.tableData = jsonData.list_data;
  324. self.loadDataCount();
  325. } catch (err) {
  326. console.log(err);
  327. }
  328. }
  329. })
  330. .catch(function(error) {
  331. console.log(error);
  332. });
  333. },
  334. changePage: function(current) {
  335. if (isNaN(current) || current < 1) {
  336. return false;
  337. }
  338. this.loadEmployeeList();
  339. }
  340. },
  341. created() {
  342. this.loadBaseData();
  343. if (this.profile.manager_type > 1) {
  344. this.loadEmployeeList();
  345. }
  346. }
  347. };
  348. </script>
  349. <style>
  350. .el-pagination {
  351. text-align: center;
  352. margin-top: 15px;
  353. }
  354. .dept_tree a.on {
  355. background-color: #f0f7ff;
  356. }
  357. .clearEmployeeBtn {
  358. cursor: pointer;
  359. color: #409eff;
  360. font-weight: normal;
  361. }
  362. .clearEmployeeBtn:hover {
  363. color: #66b1ff;
  364. }
  365. .rank_head img {
  366. width: 30px;
  367. height: 30px;
  368. -webkit-border-radius: 20px;
  369. -moz-border-radius: 20px;
  370. border-radius: 20px;
  371. margin-right: 5px;
  372. }
  373. .rank_head * {
  374. vertical-align: middle;
  375. }
  376. .check-item-box td {
  377. padding: 0;
  378. }
  379. .check-item-box .rank_head {
  380. padding: 10px;
  381. }
  382. .check-item-box .cell {
  383. padding: 0;
  384. }
  385. .check-item-box .rank_head.checked {
  386. background-color: #f0f7ff;
  387. }
  388. </style>