report.vue 13 KB

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