ExamineContrast copy 2.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <div class="contrast-container scroll-bar" style="padding-top: 10px;">
  3. <div class="flex-box-ce title-box" style="" v-if="selectExamineList && selectExamineList.length > 0">
  4. <div class="title">已选择的考核列表:</div>
  5. <el-button size="mini" @click="dialogVisible = true">查看更多</el-button>
  6. </div>
  7. <div v-if="selectExamineList && selectExamineList.length > 0" class="template-list"
  8. style="background: #f7f7f7; padding: 10px 10px 0 0; margin: 0 20px; border-radius: 4px;">
  9. <template size="small" v-for="(item, index) in selectExamineList">
  10. <el-tag :key="item.reviewPackageId" style="margin: 0 0 10px 10px;" closable
  11. @close="handleTagDelete(index)">
  12. {{ item.title }}
  13. </el-tag>
  14. </template>
  15. </div>
  16. <div v-else class="flex-box-ce" style="padding: 0 20px;">
  17. <el-button size="mini" @click="dialogVisible = true" style="margin-left: auto;">查看更多</el-button>
  18. </div>
  19. <el-tabs v-model="activeName" @tab-click="handleClick"
  20. style="width: 100%; padding: 0 20px; box-sizing: border-box;">
  21. <el-tab-pane label="表格" name="0">
  22. <el-table v-if="userList && userList.length > 0" ref="tableRef" custom-class="openAnimAbcd" id="mytable"
  23. :data="userList" style="width: 100%; " border stripe :header-cell-style="{ background: '#f5f7fa' }"
  24. v-loading="loading">
  25. <el-table-column prop="employeeName" label="姓名" align="center">
  26. </el-table-column>
  27. <el-table-column :label="item.title" v-for="(item, index) in selectExamineList"
  28. :key="item.reviewPackageId" align="center">
  29. <template slot-scope="scope">
  30. <div v-for="user in item.users">
  31. <span v-if="user.employeeId == scope.row.employeeId">{{ user.score }}</span>
  32. </div>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </el-tab-pane>
  37. <el-tab-pane label="地图" name="1" style="width: 100%;">
  38. <div v-if="treeData && JSON.stringify(treeData) !== '{}'" class="flex-box-ce scroll-bar"
  39. style="width: 100%; justify-content: center; overflow-x: auto;">
  40. <vue2-org-tree :data="treeData" style="width: 100%;" />
  41. </div>
  42. </el-tab-pane>
  43. </el-tabs>
  44. <el-dialog title="请选择需要对比的考核列表" center :visible.sync="dialogVisible" width="600px"
  45. :before-close="dialogBeforeClose">
  46. <div>
  47. <div class="search-box">
  48. <el-select v-model="cycleType" placeholder="请选择周期类型" @change="changeCircle" style="width: 100px;"
  49. size="mini">
  50. <el-option v-for="item in cycleOptions" :key="item.value" :label="item.label"
  51. :value="item.value">
  52. </el-option>
  53. </el-select>
  54. <el-date-picker v-model="date" type="daterange" align="right" unlink-panels range-separator="至"
  55. start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"
  56. :picker-options="pickerOptions" @change="changeDate" style="width: 300px; margin: 0 10px;"
  57. size="mini">
  58. </el-date-picker>
  59. <el-select v-model="status" placeholder="请选择" style="width: 100px;" @change="changeStatus"
  60. size="mini">
  61. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  62. </el-option>
  63. </el-select>
  64. <el-button plain round size="mini" style="margin-left: 10px;" @click="reset">重 置</el-button>
  65. </div>
  66. <div class="package-list">
  67. <div class="template-list scroll-bar">
  68. <template v-if="examineList && examineList.length > 0">
  69. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
  70. @change="handleCheckAllChange" style="margin-bottom: 10px;">全选</el-checkbox>
  71. <el-checkbox-group v-model="selectExamineIds" size="small" @change="changeSelectExamineIds">
  72. <template v-for="item in examineList">
  73. <el-checkbox :key="item.reviewPackageId" :label="item.reviewPackageId" border>
  74. {{ item.title }}
  75. </el-checkbox>
  76. </template>
  77. </el-checkbox-group>
  78. </template>
  79. <template v-else>
  80. <div class="flex-box-ce" style="justify-content: center;">
  81. <noData content="暂无数据" imgW="120px" imgH="80px"></noData>
  82. </div>
  83. </template>
  84. </div>
  85. <div class="choose-template scroll-bar">
  86. <el-button plain round size="mini" @click="clear">清 空</el-button>
  87. <div class="line"></div>
  88. <template v-for="(item, index) in chooseExamineList">
  89. <div class="flex-box-ce choose-template-item" style="justify-content: space-between;">
  90. <div>{{ item.title }}</div>
  91. <i class="el-icon-close" @click="deleteItem(index)"></i>
  92. </div>
  93. </template>
  94. <div ref="placeholder" style="height: 50px;"></div>
  95. </div>
  96. </div>
  97. </div>
  98. <div slot="footer">
  99. <el-button @click="dialogVisible = false">取 消</el-button>
  100. <el-button type="primary" @click="confirm">确 定</el-button>
  101. </div>
  102. </el-dialog>
  103. <div style="height: 50px;"></div>
  104. </div>
  105. </template>
  106. <script>
  107. import { mapGetters } from 'vuex';
  108. import moment from 'moment';
  109. export default {
  110. data() {
  111. return {
  112. checkAll: false,
  113. isIndeterminate: true,
  114. dialogVisible: false,
  115. activeName: "0",
  116. loading: false,
  117. treeData: {},
  118. // 周期类型 0-未定义 1-年度 2-半年度 3-季度 4-月度
  119. cycleType: '-1',
  120. cycleOptions: [
  121. { label: "全部", value: '-1' },
  122. { label: "未定义", value: '0' },
  123. { label: "年度", value: '1' },
  124. { label: "半年度", value: '2' },
  125. { label: "季度", value: '3' },
  126. { label: "月度", value: '4' },
  127. ],
  128. status: -1,
  129. options: [{
  130. value: -1,
  131. label: '全部'
  132. }, {
  133. value: '0',
  134. label: '未完成'
  135. }, {
  136. value: '1',
  137. label: '已完成'
  138. }],
  139. params: {
  140. startDate: '',
  141. endDate: '',
  142. status: -1, // 不传默认返回全部 0-未完成 1-已完成
  143. },
  144. pickerOptions: {
  145. shortcuts: [{
  146. text: '最近一周',
  147. onClick(picker) {
  148. const end = new Date();
  149. const start = new Date();
  150. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  151. picker.$emit('pick', [start, end]);
  152. }
  153. }, {
  154. text: '最近一个月',
  155. onClick(picker) {
  156. const end = new Date();
  157. const start = new Date();
  158. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  159. picker.$emit('pick', [start, end]);
  160. }
  161. }, {
  162. text: '最近三个月',
  163. onClick(picker) {
  164. const end = new Date();
  165. const start = new Date();
  166. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  167. picker.$emit('pick', [start, end]);
  168. }
  169. }]
  170. },
  171. date: [],
  172. examineList: [], // 考核表列表
  173. tableHeader: [],
  174. tableData: [],
  175. userList: [],
  176. selectExamineIds: [],
  177. selectExamineList: [],
  178. chooseExamineList: []
  179. }
  180. },
  181. // watch: {
  182. // chooseExamineList(v) {
  183. // this.selectExamineList = this.chooseExamineList
  184. // }
  185. // },
  186. filters: {
  187. formatDate(val) {
  188. if (val) return moment(val).format('YYYY-MM-DD')
  189. else return "--"
  190. }
  191. },
  192. computed: {
  193. ...mapGetters(['user_info']),
  194. // selectExamineList() {
  195. // return this.examineList.filter(item => this.selectExamineIds.includes(item.reviewPackageId))
  196. // }
  197. },
  198. created() {
  199. this.getRecords();
  200. this.dialogVisible = true;
  201. },
  202. methods: {
  203. deleteItem(index) {
  204. let chooseIndex = this.selectExamineIds.findIndex(select => select == this.chooseExamineList[index].reviewPackageId)
  205. this.selectExamineIds.splice(chooseIndex, 1)
  206. this.chooseExamineList.splice(index, 1)
  207. },
  208. changeSelectExamineIds(v) {
  209. console.log(this.selectExamineIds)
  210. if (v && v.length > 0) {
  211. this.examineList.forEach(examine => {
  212. this.selectExamineIds.forEach(val => {
  213. if (val == examine.reviewPackageId) this.chooseExamineList.push(examine)
  214. })
  215. })
  216. this.chooseExamineList = Array.from(new Set(this.chooseExamineList.map(JSON.stringify))).map(JSON.parse);
  217. } else {
  218. // this.selectExamineIds = []
  219. }
  220. },
  221. handleCheckAllChange(v) {
  222. if (v) {
  223. this.examineList.forEach(examine => {
  224. this.selectExamineIds.push(examine.reviewPackageId)
  225. })
  226. this.examineList.forEach(examine => {
  227. this.selectExamineIds.forEach(val => {
  228. if (val == examine.reviewPackageId) this.chooseExamineList.push(examine)
  229. })
  230. })
  231. this.isIndeterminate = true;
  232. this.checkAll = true;
  233. this.$nextTick(() => {
  234. if (this.$refs.placeholder) this.$refs.placeholder.scrollIntoView(false);
  235. })
  236. } else {
  237. this.selectExamineIds = [];
  238. this.isIndeterminate = false;
  239. this.checkAll = false;
  240. if (this.examineList && this.examineList.length > 0) {
  241. let examineIds = this.examineList.map(item => item.reviewPackageId)
  242. this.chooseExamineList = this.chooseExamineList.filter(choose => !examineIds.includes(choose.reviewPackageId))
  243. }
  244. }
  245. },
  246. chooseExamine(item) {
  247. if (this.selectExamineIds.includes(item.reviewPackageId)) {
  248. let index = this.selectExamineIds.findIndex(item => item.reviewPackageId);
  249. this.selectExamineIds.splice(index, 1)
  250. } else {
  251. this.selectExamineIds.push(item.reviewPackageId);
  252. }
  253. if (this.selectExamineIds.length === this.examineList.length) {
  254. this.isIndeterminate = true;
  255. this.checkAll = true;
  256. } else {
  257. this.isIndeterminate = false;
  258. this.checkAll = false;
  259. }
  260. if (this.activeName == '0') this.initTableData()
  261. if (this.activeName == '1') this.initTreeData()
  262. },
  263. handleTagDelete(index) {
  264. // 最后一个不能删除
  265. if (this.selectExamineList && this.selectExamineList.length > 1)
  266. this.selectExamineList.splice(index, 1)
  267. },
  268. getRecords() {
  269. this.loading = true;
  270. if (this.status === '-1') this.params.status = '' // 不传默认返回全部
  271. else this.params.status = this.status
  272. if (this.cycleType == '-1') this.params = { ...this.params }
  273. else {
  274. this.params = { ...this.params, cycleType: this.cycleType }
  275. }
  276. this.$axiosUser("get", `/performance/statistics/packages/${this.user_info.site_id}`, this.params).then(res => {
  277. this.loading = false;
  278. let { data: { data: { list, total }, code } } = res;
  279. this.examineList = list;
  280. if (this.examineList && this.examineList.length > 0) {
  281. this.examineList.map(item => {
  282. this.chooseExamineList.forEach(choose => {
  283. if (item.reviewPackageId == choose.reviewPackageId)
  284. this.selectExamineIds.push(item.reviewPackageId)
  285. })
  286. })
  287. }
  288. this.treeData = {
  289. id: 0,
  290. label: "考核对比",
  291. children: []
  292. }
  293. // this.selectExamineIds = [];
  294. })
  295. },
  296. initTableData() {
  297. let userList = [];
  298. let selectExamineList = [];
  299. this.examineList && this.examineList.forEach(item => {
  300. this.selectExamineIds.forEach(selectExamineId => {
  301. if (item.reviewPackageId == selectExamineId) {
  302. selectExamineList.push(item)
  303. }
  304. })
  305. })
  306. selectExamineList.forEach(item => {
  307. let { reviewPackageId, title, users } = item;
  308. if (users && users.length > 0) {
  309. users.forEach(user => {
  310. let { employeeName, employeeId } = user
  311. userList.push({ employeeName, employeeId })
  312. })
  313. }
  314. })
  315. this.userList = userList.reduce((acc, obj) => {
  316. // 检查当前对象是否已经存在于结果数组中
  317. if (!acc.find(item => item.employeeId === obj.employeeId)) { // 假设我们通过id来判断唯一性
  318. acc.push(obj);
  319. }
  320. return acc;
  321. }, []);
  322. },
  323. initTreeData() {
  324. this.selectExamineList.forEach(item => {
  325. item.id = Date.now() + Math.floor(Math.random() * 10000);
  326. item.label = item.title;
  327. item.children = item.users;
  328. item.users.forEach(user => {
  329. user.id = Date.now() + Math.floor(Math.random() * 10000);
  330. user.label = user.employeeName + ", " + (user.score ? user.score : 0);
  331. })
  332. })
  333. this.treeData = {
  334. id: 0,
  335. label: "考核对比",
  336. children: this.selectExamineList
  337. }
  338. },
  339. handleClick(tab, event) {
  340. if (this.activeName == '0') this.initTableData()
  341. if (this.activeName == '1') this.initTreeData()
  342. },
  343. // 日期选择时间
  344. changeDate(v) {
  345. if (v && v.length > 0) {
  346. this.params.startDate = v[0] || ''
  347. this.params.endDate = v[1] || ''
  348. this.getRecords();
  349. }
  350. },
  351. //选择周期
  352. changeCircle(v) {
  353. this.getRecords();
  354. },
  355. // 选择状态
  356. changeStatus(v) {
  357. this.getRecords();
  358. },
  359. // 重置搜索条件
  360. reset() {
  361. this.cycleType = '-1'
  362. this.status = -1
  363. this.date = []
  364. this.params = {
  365. startDate: '',
  366. endDate: '',
  367. status: -1, // 不传默认返回全部 0-未完成 1-已完成
  368. }
  369. this.getRecords();
  370. },
  371. // 清空选择的考核列表
  372. clear() {
  373. this.selectExamineIds = [];
  374. this.chooseExamineList = [];
  375. },
  376. dialogBeforeClose() {
  377. this.dialogVisible = false;
  378. },
  379. confirm() {
  380. this.selectExamineList = this.chooseExamineList;
  381. if (this.activeName == '0') this.initTableData()
  382. if (this.activeName == '1') this.initTreeData()
  383. this.dialogVisible = false;
  384. }
  385. },
  386. }
  387. </script>
  388. <style scoped="scoped" lang="scss">
  389. .contrast-container {
  390. width: 100%;
  391. height: 100%;
  392. background-color: #fff;
  393. .el-icon-close {
  394. transition: all 0.2s;
  395. &:hover {
  396. font-size: 16px;
  397. }
  398. }
  399. .search-box {
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. box-sizing: border-box;
  404. }
  405. .title-box {
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. margin-bottom: 10px;
  410. padding: 0 20px;
  411. .title {
  412. color: #999;
  413. font-size: 14px;
  414. font-weight: bold;
  415. }
  416. }
  417. .package-list {
  418. width: 100%;
  419. height: 400px;
  420. display: flex;
  421. margin-top: 10px;
  422. border: 1px solid #f7f7f7;
  423. .template-list {
  424. width: 50%;
  425. height: 400px;
  426. overflow-y: auto;
  427. display: flex;
  428. flex-direction: column;
  429. border-right: 1px solid #f7f7f7;
  430. padding: 10px;
  431. box-sizing: border-box;
  432. .el-checkbox-group {
  433. width: 100% !important;
  434. height: 100% !important;
  435. .el-checkbox {
  436. margin: 0;
  437. width: 200px;
  438. margin-bottom: 10px;
  439. }
  440. }
  441. }
  442. .choose-template {
  443. width: 50%;
  444. height: 400px;
  445. overflow-y: auto;
  446. padding: 10px;
  447. box-sizing: border-box;
  448. .line {
  449. width: 90%;
  450. height: 1px;
  451. background-color: #f7f7f7;
  452. margin: 10px auto;
  453. }
  454. &-item {
  455. width: 90%;
  456. height: 30px;
  457. line-height: 30px;
  458. padding-left: 10px;
  459. border-bottom: 1px solid #f7f7f7;
  460. margin: 0 auto 10px auto;
  461. box-sizing: border-box;
  462. }
  463. }
  464. }
  465. .table-box {
  466. width: 100%;
  467. padding: 0 20px;
  468. box-sizing: border-box;
  469. }
  470. /* 设置滚动条的宽度和背景色 */
  471. ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  472. width: 10px;
  473. height: 10px;
  474. background-color: #f9f9f9;
  475. }
  476. /* 设置滚动条滑块的样式 */
  477. ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  478. border-radius: 6px;
  479. background-color: #c1c1c1;
  480. }
  481. /* 设置滚动条滑块hover样式 */
  482. ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb:hover {
  483. background-color: #a8a8a8;
  484. }
  485. /* 设置滚动条轨道的样式 */
  486. ::v-deep .el-table__body-wrapper::-webkit-scrollbar-track {
  487. box-shadow: inset 0 0 5px rgba(87, 175, 187, 0.1);
  488. border-radius: 6px;
  489. background: #ededed;
  490. }
  491. }
  492. </style>