approval_batch.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div>
  3. <div class="diy_tip_bg">
  4. <el-alert class="diy-tip" type="success" @close="tips_close" v-if="tips_show">
  5. <p style="font-size: 14px;">批量审批仅支持快速处理任务审批和已指定规则的积分审批,其余情况的审批单请到【待我审批】处理
  6. </br>权限分不足时,请进入【审批详情】→【通过】→【递交审批】给上级
  7. </p>
  8. </el-alert>
  9. </div>
  10. <div class="all padding-20">
  11. <FormBox>
  12. <div class="form-item">
  13. <div class="form-label">姓名搜索</div>
  14. <div class="form-search">
  15. <el-select size="medium" v-model="target_id" filterable collapse-tags clearable
  16. placeholder="请输入或选择人员">
  17. <el-option v-for="item in employee_map" :key="item.id" :label="item.name"
  18. :value="item.id"></el-option>
  19. </el-select>
  20. </div>
  21. </div>
  22. <div class="form-item">
  23. <div class="form-label">内容搜索</div>
  24. <div class="form-search">
  25. <el-input size="medium" max="20" v-model="formData.keyword" placeholder="请输入"
  26. clearable></el-input>
  27. </div>
  28. </div>
  29. </FormBox>
  30. <div style="margin: 10px 0;">
  31. <el-button size="medium" type="primary" plain @click="pass">批量通过</el-button>
  32. <el-button size="medium" type="danger" plain @click="reject">批量驳回</el-button>
  33. </div>
  34. <el-table :data="list" style="width: 100%;cursor: pointer;" v-loading="loading"
  35. @selection-change="deleteEvents" @row-click="openDetail">
  36. <el-table-column width="50" type="selection"></el-table-column>
  37. <el-table-column label="" prop="task_name">
  38. <template slot-scope="scope">
  39. <div class="flex-box flex-v-ce">
  40. <userImage width="50px" height="50px" :id="scope.row.employee_id"
  41. :user_name="scope.row.employee_name"></userImage>
  42. <div style="margin-left: 5px;">
  43. <span class="tableTitle" v-show="scope.row.source_type == 1">{{ scope.row.employee_name
  44. }}的积分任务</span>
  45. <span class="tableTitle" v-show="scope.row.source_type == 2">{{ scope.row.employee_name
  46. }}的积分申请</span>
  47. <span class="tableTitle" v-show="scope.row.source_type == 3">{{ scope.row.employee_name
  48. }}的积分奖扣</span>
  49. <span class="tableTitle" v-show="scope.row.source_type == 4">{{ scope.row.employee_name
  50. }}的绩效工作</span>
  51. </div>
  52. </div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="point" label="积分" align="center">
  56. <template slot-scope="scope">
  57. <span class="green" v-if="scope.row.point > 0">+{{ scope.row.point }}
  58. {{$getTyps(scope.row.pt_id).name}}</span>
  59. <span class="red" v-else>{{ scope.row.point }} {{$getTyps(scope.row.pt_id).name}}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="审批内容" prop="remark" min-width="200">
  63. <template slot-scope="scope">
  64. <span class="font-flex-word">{{ scope.row.remark.customize || scope.row.remark.rule }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="时间" prop="event_time" width="150"></el-table-column>
  68. <el-table-column prop="remark" label="操作" align="center">
  69. <template slot-scope="scope">
  70. <span class="blue" style="cursor: pointer;">审批</span>
  71. </template>
  72. </el-table-column>
  73. <template slot="empty">
  74. <noData></noData>
  75. </template>
  76. </el-table>
  77. <center style="padding: 20px 0;">
  78. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  79. :current-page="formData.page" :page-sizes="[10, 20, 50, 100]"
  80. layout="total, sizes, prev, pager, next" :page-size="formData.page_size"
  81. :total="total"></el-pagination>
  82. </center>
  83. </div>
  84. <examinePopup :title="'审核详情'" :id="detail_id" :show.sync="detailShow"></examinePopup>
  85. <el-dialog title="审批驳回" :visible.sync="rejectShow" width="520px">
  86. <div style="text-align: center;margin-bottom: 10px;" class="fontColorB">
  87. 已选中{{selectionID.length}}条审批单,确认全部驳回吗?</div>
  88. <el-form :model="rejectForm" ref="rejectForm" label-width="80px" style="margin-top: 20px;">
  89. <el-form-item label="审批意见" prop="remark"
  90. :rules="[{ required: true, message: '请输入审批意见', trigger: 'blur' }, { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' }]">
  91. <el-input type="textarea" :rows="4" v-model="rejectForm.remark"
  92. placeholder="请输入审批意见(限50字)"></el-input>
  93. </el-form-item>
  94. <el-form-item style="text-align: right; margin-bottom: 0">
  95. <el-button @click="rejectShow = false">取消</el-button>
  96. <el-button type="primary" @click="confirmReject()">确认驳回</el-button>
  97. </el-form-item>
  98. </el-form>
  99. </el-dialog>
  100. <!-- 审批结果 -->
  101. <el-dialog title="提交结果" :visible.sync="isResult" width="800" :close-on-click-modal="false"
  102. :close-on-press-escape="false" :show-close="false">
  103. <div v-if="!isShowError">
  104. <el-progress :text-inside="true" :stroke-width="24" :percentage="percentage"></el-progress>
  105. <div style="margin-top: 20px;border: 1px solid #f1f1f1;">
  106. <div class="flex-box-ce results" style="font-weight: 600;">
  107. <div style="border-right: 1px solid #f1f1f1;width: 50px;">序号</div>
  108. <div class="flex-1" style="border-right: 1px solid #f1f1f1;">奖扣对象</div>
  109. <div class="flex-2" style="border-right: 1px solid #f1f1f1;">审批内容</div>
  110. <div class="flex-1" style="border-right: 1px solid #f1f1f1;">积分</div>
  111. <div class="flex-2">处理结果</div>
  112. </div>
  113. <div class="flex-box-ce results" v-for="(item, index) in results" :key="index">
  114. <div style="border-right: 1px solid #f1f1f1;width: 50px;">{{results.length-index}}</div>
  115. <div class="flex-1" style="border-right: 1px solid #f1f1f1;">{{ item.name }}</div>
  116. <div class="flex-2" style="border-right: 1px solid #f1f1f1;">{{ item.remark.customize ||
  117. item.remark.rule }}</div>
  118. <div class="flex-1" style="border-right: 1px solid #f1f1f1;">
  119. {{ item.point>0? '+'+item.point:item.point }}
  120. <span>{{ item.pt_id==3? 'B分':'A分' }}</span>
  121. </div>
  122. <div class="flex-2 green" v-if="item.status == 1">{{ item.msg }}</div>
  123. <div class="flex-2 red" v-else>{{ item.msg }}</div>
  124. </div>
  125. </div>
  126. <span slot="footer">
  127. <div class="flex-box-end" style="margin-top: 20px;" v-show="results.length==resultList.length">
  128. <el-button type="primary" @click="isResult = false" size="small">确 定</el-button>
  129. </div>
  130. </span>
  131. </div>
  132. <div v-else>
  133. <div style="text-align: center;" class="red">服务器繁忙,请稍后再试</div>
  134. <span slot="footer">
  135. <div class="flex-box-end" style="margin-top: 20px;"><el-button type="primary"
  136. @click="isResult = false" size="small">确 定</el-button></div>
  137. </span>
  138. </div>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. import examinePopup from '@/components/examinePopup.vue';
  144. import { _debounce, getToken } from '@/api/auth';
  145. var setIntervalWesocketPush = null;
  146. export default {
  147. components: { examinePopup },
  148. data() {
  149. return {
  150. detailShow: false,
  151. detail_id: null,
  152. employee_map: this.$getCache('SET_EMPLOYEE_MAP'),
  153. total: 0,
  154. target_id: '',
  155. formData: {
  156. target_id: '',
  157. type: 'waiting',
  158. keyword: '',
  159. batch: 1,
  160. page: 1,
  161. pt_id: '0',
  162. page_size: 10,
  163. source_type: '0',
  164. reviewer_id:this.$getUserData().id,
  165. },
  166. loading: false,
  167. list: [],
  168. selectionID: [],
  169. rejectShow: false,
  170. rejectForm: {
  171. remark: ''
  172. },
  173. // 长连接结果
  174. results: [], //提交的返回结果集合
  175. isResult: false,
  176. percentage: 0,
  177. resultList:[],//要发送数据的集合
  178. resultIndex:0,
  179. isShowError:false,
  180. tips_show: false,
  181. };
  182. },
  183. watch: {
  184. isResult(val) {
  185. if (!val) {
  186. this.isShowError = false;
  187. this.percentage = 0;
  188. this.results = [];
  189. this.selectionItems = [];
  190. this.getSpList();
  191. this.$socketApiTow.closewebsocket();
  192. }
  193. },
  194. target_id(val) {
  195. this.formData.page = 1;
  196. this.formData.target_id = val;
  197. this.getSpList();
  198. },
  199. 'formData.keyword': {
  200. deep: true,
  201. handler: _debounce(function(val) {
  202. this.formData.page = 1;
  203. this.getSpList();
  204. }, 1000)
  205. },
  206. rejectShow(val) {
  207. if (!val) {
  208. this.rejectForm.remark = '';
  209. }
  210. }
  211. },
  212. created() {
  213. this.getEmployeeList();
  214. },
  215. mounted() {
  216. if (this.$getCache('voluntarilyPoint')) {
  217. this.tips_show = false;
  218. } else {
  219. this.tips_show = true;
  220. }
  221. this.getSpList();
  222. },
  223. methods: {
  224. // 关闭提示语
  225. tips_close() {
  226. this.$setCache('voluntarilyPoint', 'true');
  227. this.tips_show = false;
  228. },
  229. // 详情
  230. openDetail(item) {
  231. this.detail_id = item.id;
  232. this.detailShow = true;
  233. },
  234. // 确定驳回
  235. confirmReject() {
  236. if (!this.rejectForm.remark) {
  237. this.$message.error('请输入审批意见');
  238. return false;
  239. }
  240. this.rejectShow = false;
  241. this.webSocket(false);
  242. },
  243. //驳回
  244. reject() {
  245. if (this.selectionID.length == 0) {
  246. this.$message.error('请选择审批单');
  247. return false;
  248. }
  249. this.rejectShow = true;
  250. },
  251. //通过
  252. pass() {
  253. if (this.selectionID.length == 0) {
  254. this.$message.error('请选择审批单');
  255. return false;
  256. }
  257. this.$confirm(`已选中${this.selectionID.length}条审批单,确认全部通过?`, '提示', {
  258. confirmButtonText: '确定',
  259. cancelButtonText: '取消',
  260. type: 'warning'
  261. })
  262. .then(() => {
  263. this.webSocket(true);
  264. }).catch(() => {});
  265. },
  266. webSocket(is){
  267. let arr=[];
  268. let wsData;
  269. this.selectionID.forEach(item => {
  270. if(is){
  271. wsData = {
  272. type: 'review',
  273. action: 'complete',
  274. review_id: item
  275. };
  276. }else{
  277. wsData = {
  278. type: 'review',
  279. action: 'refuse',
  280. review_id: item,
  281. remark: this.rejectForm.remark
  282. };
  283. }
  284. arr.push(wsData);
  285. });
  286. this.resultList=arr;
  287. this.resultIndex=0;
  288. this.percentage=0;
  289. this.results=[];
  290. this.isResult=true;
  291. this.opneWebSocket()
  292. },
  293. opneWebSocket() {
  294. let wsData=this.resultList;
  295. if(wsData[this.resultIndex]){
  296. this.$socketApiTow.sendData(wsData[this.resultIndex],this.onmessageWS)
  297. }
  298. },
  299. onmessageWS(e){
  300. if(e.type=='review'){
  301. let item=this.selectionItems[this.resultIndex];
  302. let result=e.result;
  303. result.name=item.employee_name
  304. result.remark=item.remark
  305. result.point=item.point
  306. result.pt_id=item.pt_id
  307. this.results.push(e.result);
  308. this.resultIndex++;
  309. this.opneWebSocket();
  310. // 进度条
  311. let lng = this.resultList.length;
  312. this.percentage = Math.floor(this.resultIndex / (lng / 100))
  313. if (lng == this.results.length) {
  314. this.percentage = 100;
  315. }
  316. }
  317. if(e.type=='error'||e.type=='break'){
  318. this.isShowError = true;
  319. }
  320. },
  321. searchFun() {
  322. this.dataList = [];
  323. this.total = 0;
  324. this.formData.page = 1;
  325. this.getSpList();
  326. },
  327. deleteEvents(selection) {
  328. this.selectionItems = selection;
  329. this.selectionID = selection.map(item => {
  330. return item.id;
  331. });
  332. },
  333. getEmployeeList() {
  334. this.$axios('get', '/api/employee/list', {}).then(res => {
  335. if (res.data.code == 1) {
  336. this.employee_map = res.data.data.list;
  337. }
  338. });
  339. },
  340. exportExcel() {
  341. window.open();
  342. },
  343. // 页面变更
  344. handleCurrentChange(val) {
  345. this.formData.page = val;
  346. this.getSpList();
  347. },
  348. handleSizeChange(val) {
  349. this.formData.page = 1;
  350. this.formData.page_size = val;
  351. this.getSpList();
  352. },
  353. //请求数据
  354. getSpList() {
  355. this.loading = true;
  356. if (!this.formData.target_id) {
  357. delete this.formData.target_id;
  358. }
  359. this.$axios('get', '/api/integral/review/list', this.formData)
  360. .then(res => {
  361. this.list = res.data.data.list;
  362. this.total = res.data.data.total;
  363. if(this.formData.page!=1&&this.list.length==0){
  364. this.formData.page = 1;
  365. this.getSpList();
  366. }
  367. })
  368. .finally(() => {
  369. this.loading = false;
  370. });
  371. }
  372. }
  373. };
  374. </script>
  375. <style scoped>
  376. .results {
  377. border-bottom: 1px solid #f1f1f1;
  378. text-align: center;
  379. }
  380. .results div {
  381. padding: 10px;
  382. }
  383. .el-date-editor.el-input {
  384. width: auto;
  385. }
  386. .date-picker-width {
  387. width: 145px !important;
  388. }
  389. .search ::v-deep .el-input-group__append:active {
  390. background: #26a2ff;
  391. }
  392. .search ::v-deep .el-input-group__append:active .el-icon-search {
  393. color: #fff;
  394. }
  395. .diy_tip_bg {
  396. background: #f5f6f9;
  397. overflow: hidden;
  398. .diy-tip {
  399. margin-bottom: 15px;
  400. border: 1px solid #67c23a;
  401. padding: 20px 16px;
  402. p {
  403. color: #67c23a !important;
  404. font-size: 16px;
  405. margin: 0 !important;
  406. padding: 4px 0;
  407. }
  408. }
  409. }
  410. ::v-deep .el-dialog__body {
  411. padding: 0px 20px 30px;
  412. }
  413. </style>