report.vue 15 KB

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