ExamineContrast copy 3.vue 21 KB

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