report.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <section >
  3. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  4. <el-form :inline="true">
  5. <el-form-item :label="$t('approvalprocesssetting')">
  6. </el-form-item>
  7. </el-form>
  8. </el-col>
  9. <p style="padding-top:80px;margin: 0 0 10px 10px;color:#666;">{{$t('timeApprovalProcess')}}</p>
  10. <div>
  11. <el-col :span="6" >
  12. <el-scrollbar style="height:100%;border:1px solid #dddddd;margin-left:15px;" >
  13. <div class="tree" :style="'height:'+ (tableHeight-120) + 'px'">
  14. <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" accordion>
  15. <span class="custom-tree-node" slot-scope="{ node, data }">
  16. <!-- <span>{{ node.label }}</span> -->
  17. <span v-if="user.userNameNeedTranslate == '1'">
  18. <TranslationOpenDataText type='departmentName' :openid='node.label'></TranslationOpenDataText>
  19. </span>
  20. <span v-else>
  21. {{ node.label }}
  22. </span>
  23. </span>
  24. </el-tree>
  25. </div>
  26. </el-scrollbar>
  27. </el-col>
  28. <el-col :span="18" >
  29. <el-scrollbar style="height:100%;border:1px solid #dddddd;margin-right:20px;" >
  30. <div class="tree" :style="'height:'+ (tableHeight-120) + 'px'">
  31. <div style="padding:5px;color:#333;" v-if="depData != null">{{ $t('setup') }} &lt;<span style="color:#20a0ff;">
  32. <span v-if="user.userNameNeedTranslate != 1">{{depData.label}}</span>
  33. <span v-if="user.userNameNeedTranslate == 1"><TranslationOpenDataText type='departmentName' :openid='depData.label'></TranslationOpenDataText></span>
  34. &gt;</span> {{ $t('workinghoursapprovalprocessofdirectstaff') }}
  35. <el-tooltip effect="dark" v-if="depData != null && depData.children!=null" :content="$t('onlyapplicabletotheimmediatestaffofthecurrentdepartment')" placement="top-start">
  36. <i class="el-icon-question"></i>
  37. </el-tooltip>
  38. </div>
  39. <div style="padding:5px;" v-if="depData == null">{{ $t('qing-xuan-ze-bu-men') }}</div>
  40. <div style="width:100%;margin:0 auto;text-align: center; margin-top:50px;" v-if="depData != null">
  41. <span>{{ $t('employeeisallowed') }}</span>
  42. <icon class="iconfont firerock-iconright"></icon>
  43. <icon class="iconfont firerock-iconInsertLine addNode" @click="showNodeDialog(0)"></icon>
  44. <icon class="iconfont firerock-iconright"></icon>
  45. <span v-for="(item, index) in dataArray" :key="item.seq" >
  46. <el-button type="primary" v-if="item.isDeptAudit == 1" @click="editNodeDialog(index, item)">
  47. <span v-if="user.userNameNeedTranslate != 1">{{item.auditDeptName}}</span>
  48. <span v-if="user.userNameNeedTranslate == 1">
  49. <TranslationOpenDataText type='departmentName' :openid='item.auditDeptName'></TranslationOpenDataText>
  50. </span>
  51. </el-button>
  52. <el-button type="primary" v-if="item.isDeptAudit == 0" >{{ $t('other.projectAuditor') }}</el-button>
  53. <icon class="iconfont firerock-iconright"></icon>
  54. <icon class="iconfont firerock-iconInsertLine addNode" @click="showNodeDialog(index+1)"></icon>
  55. <icon class="iconfont firerock-iconright"></icon>
  56. </span>
  57. <!--结束点 -->
  58. <icon class="iconfont firerock-iconApp_New_Line" style="color:#20A0FF;"></icon>
  59. {{ $t('approvaltocomplete') }}
  60. </div>
  61. <div style="width:100%;margin:0 auto;margin-bottom:30px;position: absolute;bottom: 0px;text-align: center; ">
  62. <el-button type="primary" @click="submitInsert" :loading="addLoading">{{ $t('save') }}</el-button>
  63. </div>
  64. </div>
  65. </el-scrollbar>
  66. </el-col>
  67. </div>
  68. <!--部门选择列表 -->
  69. <el-dialog :title="$t('selectheapprovingdepartment')" v-if="dialogVisible" :visible.sync="dialogVisible" width="400px">
  70. <el-form label-width="80px">
  71. <el-form-item :label="$t('other.selectdepartment')" >
  72. <el-cascader ref="deptCascader" v-model="curDeptId" :placeholder="$t('qing-xuan-ze-bu-men')" style="width: 100%" @change="chooseDept"
  73. :options="option" :props="{ checkStrictly: true,expandTrigger: 'hover' }" :show-all-levels="false" clearable v-show="user.userNameNeedTranslate != 1"></el-cascader>
  74. <vueCascader :size="'small'" :subjectId="curDeptId" :widthStr="'200'" :clearable="true" :subject="option" :radios="true" :distinction="'3'" @vueCasader="vueCasader" v-if="user.userNameNeedTranslate == 1"></vueCascader>
  75. </el-form-item>
  76. </el-form>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button type="default" @click="deleteNode" v-if="!isAdd" style="float:left;">{{ $t('btn.delete') }}</el-button>
  79. <el-button type="primary" @click="addNode" >{{ $t('btn.determine') }}</el-button>
  80. </div>
  81. </el-dialog>
  82. <!--管理员设置 -->
  83. <el-dialog :title="$t('electanapprovaladministrator')" v-if="userDialogVisible" :visible.sync="userDialogVisible" width="400px">
  84. <el-form label-width="100px">
  85. <el-form-item :label="$t('dministrator')" >
  86. <el-select v-model="auditManagerId" >
  87. <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  88. </el-select>
  89. </el-form-item>
  90. </el-form>
  91. <div slot="footer" class="dialog-footer">
  92. <el-button type="primary" @click="setAuditUser" >{{ $t('btn.determine') }}</el-button>
  93. </div>
  94. </el-dialog>
  95. </section>
  96. </template>
  97. <script>
  98. import util from "../../common/js/util";
  99. // 引入自定义级联组件
  100. import vueCascader from "@/components/cascader.vue"
  101. export default {
  102. data() {
  103. return {
  104. data: [
  105. ],
  106. option: [],
  107. depData:null,
  108. defaultProps: {
  109. children: 'children',
  110. label: 'label'
  111. },
  112. userDialogVisible: false,
  113. auditManagerId:null,
  114. isAdd: false,
  115. dataArray:[],
  116. curDeptId:null,
  117. curUserId: null,
  118. index:0,
  119. roleArray:[
  120. {label:this.$t('role.projectManager'),value:5},
  121. {label:this.$t('departmenthead'),value:6},
  122. {label:this.$t('personnelAdministrator'),value:4},
  123. ],
  124. dialogVisible:false,
  125. editNode:{},
  126. user: JSON.parse(sessionStorage.getItem("user")),
  127. userList:[],
  128. sysAuditUSer:{},
  129. addNodeObj: {}
  130. };
  131. },
  132. components: {
  133. vueCascader
  134. },
  135. methods: {
  136. setAuditUser() {
  137. this.http.post('/audit-workflow-time-setting/setAuditSysUser',{userId: this.auditManagerId},
  138. res => {
  139. this.listLoading = false;
  140. if (res.code == "ok") {
  141. this.sysAuditUSer = res.data;
  142. this.userDialogVisible = false;
  143. this.$message({
  144. message: this.$t('setupthesuccess'),
  145. type: "success"
  146. });
  147. } else {
  148. this.$message({
  149. message: res.msg,
  150. type: "error"
  151. });
  152. }
  153. },
  154. error => {
  155. this.listLoading = false;
  156. this.$message({
  157. message: error,
  158. type: "error"
  159. });
  160. }
  161. );
  162. },
  163. showUserDialog() {
  164. this.userDialogVisible = true;
  165. this.auditManagerId = this.sysAuditUSer.id;
  166. },
  167. getAuditSysUser() {
  168. this.http.post('/audit-workflow-time-setting/getAuditSysUser',{},
  169. res => {
  170. this.listLoading = false;
  171. if (res.code == "ok") {
  172. this.sysAuditUSer = res.data;
  173. } else {
  174. this.$message({
  175. message: res.msg,
  176. type: "error"
  177. });
  178. }
  179. },
  180. error => {
  181. this.listLoading = false;
  182. this.$message({
  183. message: error,
  184. type: "error"
  185. });
  186. }
  187. );
  188. },
  189. // 获取部门列表
  190. getDepartment() {
  191. this.http.post( this.port.manage.depList, {},
  192. res => {
  193. if (res.code == "ok") {
  194. var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
  195. this.data = list;
  196. this.option = this.changeArr(list1);
  197. } else {
  198. this.$message({
  199. message: res.msg,
  200. type: "error"
  201. });
  202. }
  203. },
  204. error => {
  205. this.$message({
  206. message: error,
  207. type: "error"
  208. });
  209. });
  210. },
  211. // 修改数组
  212. changeArr(arr) {
  213. for (var i = 0; i < arr.length; i++) {
  214. if(arr[i].id != -1 && arr[i].id != 0) {
  215. if (arr[i].children != null && arr[i].children.length>0) {
  216. arr[i].children = this.changeArr(arr[i].children);
  217. }
  218. arr[i].id && (arr[i].value = arr[i].id);
  219. delete arr[i].id;
  220. }
  221. }
  222. for(var i in arr) {
  223. if(arr[i].id == -1 || arr[i].id == 0) {
  224. arr.splice(i,1)
  225. }
  226. }
  227. return arr;
  228. },
  229. // 部门列表点击
  230. handleNodeClick(data) {
  231. if(this.depData == null || data.id != this.depData.id) {
  232. this.depData = data;
  233. console.log(this.depData);
  234. this.getSettings();
  235. }
  236. },
  237. deleteNode() {
  238. this.dialogVisible = false;
  239. this.dataArray.splice(this.index, 1);
  240. },
  241. addNode() {
  242. if (this.curDeptId == null) return;
  243. this.dialogVisible = false;
  244. var node = ''
  245. if(this.user.userNameNeedTranslate != 1) {
  246. node = this.$refs.deptCascader.getCheckedNodes()[0];
  247. } else {
  248. node = this.addNodeObj
  249. }
  250. console.log(node)
  251. if (this.isAdd) {
  252. var node = {auditDeptId: node.value, auditDeptName: node.label, isDeptAudit:1};
  253. this.dataArray.splice(this.index, 0, node);
  254. console.log(this.dataArray);
  255. } else {
  256. //编辑
  257. this.dataArray[this.index].auditDeptId = node.value;
  258. this.dataArray[this.index].auditDeptName = node.label;
  259. }
  260. },
  261. // 判断部门
  262. judgmentDepartment(id, item, index) {
  263. this.http.post('/audit-workflow-time-setting/approveDeptAuditReport',{
  264. auditDeptId: id,
  265. },
  266. res => {
  267. this.listLoading = false;
  268. if (res.code == "ok") {
  269. this.$message({
  270. type: 'success',
  271. message: '操作成功!'
  272. });
  273. this.isAdd = false;
  274. this.index = index;
  275. this.curUserId = item.userId;
  276. this.dialogVisible = true;
  277. this.curDeptId = item.auditDeptId;
  278. } else {
  279. this.$message({
  280. message: res.msg,
  281. type: "error"
  282. });
  283. }
  284. },
  285. error => {
  286. this.listLoading = false;
  287. this.$message({
  288. message: error,
  289. type: "error"
  290. });
  291. });
  292. },
  293. editNodeDialog(index, item) {
  294. //检查是否可编辑
  295. this.http.post('/audit-workflow-time-setting/checkNodeInUse',{auditDeptId: item.auditDeptId, deptId: this.depData.id},
  296. res => {
  297. this.listLoading = false;
  298. if (res.code == "ok") {
  299. this.isAdd = false;
  300. this.index = index;
  301. this.curUserId = item.userId;
  302. this.dialogVisible = true;
  303. this.curDeptId = item.auditDeptId;
  304. } else {
  305. if(res.msg.indexOf('当前部门存在待审核报告') != '-1') {
  306. this.$confirm('当前部门存在待审核报告, 是否全部转为通过?', '提示', {
  307. confirmButtonText: '确定',
  308. cancelButtonText: '取消',
  309. type: 'warning'
  310. }).then(() => {
  311. this.judgmentDepartment(item.auditDeptId, item, index)
  312. }).catch(() => {});
  313. } else {
  314. this.$message({
  315. message: res.msg,
  316. type: "error"
  317. });
  318. }
  319. }
  320. },
  321. error => {
  322. this.listLoading = false;
  323. this.$message({
  324. message: error,
  325. type: "error"
  326. });
  327. }
  328. );
  329. },
  330. showNodeDialog(index) {
  331. this.isAdd = true;
  332. this.index = index;
  333. this.curDeptId = null;
  334. this.curUserId = null;
  335. this.dialogVisible = true;
  336. },
  337. submitInsert() {
  338. this.http.post('/audit-workflow-time-setting/add',{json:JSON.stringify(this.dataArray), deptId: this.depData.id},
  339. res => {
  340. this.listLoading = false;
  341. if (res.code == "ok") {
  342. this.$message({
  343. message: this.$t('savesuccess'),
  344. type: "success"
  345. });
  346. } else {
  347. this.$message({
  348. message: res.msg,
  349. type: "error"
  350. });
  351. }
  352. },
  353. error => {
  354. this.listLoading = false;
  355. this.$message({
  356. message: error,
  357. type: "error"
  358. });
  359. }
  360. );
  361. },
  362. // 获取本公司的工时日报审批流程设置
  363. getSettings() {
  364. this.http.post('/audit-workflow-time-setting/get',{deptId: this.depData.id},
  365. res => {
  366. this.listLoading = false;
  367. if (res.code == "ok") {
  368. this.dataArray = res.data;
  369. console.log(this.data);
  370. } else {
  371. this.$message({
  372. message: res.msg,
  373. type: "error"
  374. });
  375. }
  376. },
  377. error => {
  378. this.listLoading = false;
  379. this.$message({
  380. message: error,
  381. type: "error"
  382. });
  383. }
  384. );
  385. },
  386. vueCasader(obj) {
  387. if(obj.distinction == '3') {
  388. let arr = []
  389. arr.push(obj.id)
  390. this.curDeptId = arr
  391. this.addNodeObj = obj.item
  392. }
  393. }
  394. },
  395. created() {
  396. let height = window.innerHeight;
  397. this.tableHeight = height - 195;
  398. const that = this;
  399. window.onresize = function temp() {
  400. that.tableHeight = window.innerHeight - 195;
  401. };
  402. },
  403. mounted() {
  404. this.getDepartment();
  405. }
  406. };
  407. </script>
  408. <style lang="scss" scoped>
  409. .addNode {
  410. cursor:pointer;
  411. }
  412. .addNode:hover {
  413. color:#20a0ff;
  414. }
  415. .panel {
  416. padding:30px 15px ;box-shadow: 0 2px 4px rgba(3, 3, 3, 0.12), 0 0 6px rgba(0, 0, 0, .04);
  417. }
  418. .sample {
  419. margin-top:30px;
  420. color: #999;
  421. }
  422. .tip {
  423. margin-left:10px; color:gray;
  424. }
  425. </style>