ResultInput.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <div>
  3. <el-dialog :title="dialogTitle" center :visible.sync="resultInput" width="600px"
  4. :before-close="handleCloseDialog">
  5. <div v-if="currentNode">
  6. <el-form ref="form" label-width="80px" size="small">
  7. <el-form-item label="启用">
  8. <el-switch v-model="currentNode.enable"></el-switch>
  9. </el-form-item>
  10. <el-form-item :label="formLabel">
  11. <el-radio-group v-model="currentNode.assigneeType" :disabled="!currentNode.enable">
  12. <el-radio-button label="leader">管理员</el-radio-button>
  13. <el-radio-button label="user">指定人员</el-radio-button>
  14. <el-radio-button label="self">被考核人</el-radio-button>
  15. <el-radio-button label="post">岗位</el-radio-button>
  16. <el-radio-button label="deptLeader">部门</el-radio-button>
  17. </el-radio-group>
  18. </el-form-item>
  19. <el-form-item v-if="currentNode.assigneeType === 'leader'">
  20. <el-select :key="idGeneral()" v-model="selected_manager_ids" placeholder="请选择管理员"
  21. :disabled="!currentNode.enable" filterable style="width: 300px;" @change="changeManagerIds">
  22. <el-option v-for="item in levelOptions" :key="item.value" :label="item.label"
  23. :value="item.value" style="width: 300px;"></el-option>
  24. </el-select>
  25. <br>
  26. <div class="fontColorC">(<span style="color: red"> * </span>组织架构中,所设置的部门管理员 )</div>
  27. </el-form-item>
  28. <el-form-item v-if="currentNode.assigneeType === 'user'">
  29. <el-select :key="idGeneral()" v-model="selected_employee_ids" placeholder="请选择指定人员" multiple
  30. :disabled="!currentNode.enable" filterable style="width: 300px;"
  31. @change="changeEmployeeIds">
  32. <el-option v-for="item in employeeMap" :key="item.id" :label="item.name" :value="item.id"
  33. style="width: 300px;"></el-option>
  34. </el-select>
  35. <br>
  36. <div class="fontColorC">(<span style="color: red"> * </span>组织架构中,所设置的部门管理员 )</div>
  37. </el-form-item>
  38. <el-form-item v-if="currentNode.assigneeType === 'post'">
  39. <el-select :key="idGeneral()" v-model="selected_post_ids" placeholder="请选择岗位" multiple
  40. :disabled="!currentNode.enable" filterable style="width: 300px;" @change="changePostIds">
  41. <el-option v-for="item in postList" :key="item.id" :label="item.name" :value="item.id"
  42. style="width: 300px;"></el-option>
  43. </el-select>
  44. <br>
  45. <div class="fontColorC">(<span style="color: red"> * </span>组织架构中,所设置的部门管理员 )</div>
  46. </el-form-item>
  47. <el-form-item v-if="currentNode.assigneeType === 'deptLeader'">
  48. <el-cascader :key="idGeneral()" ref="deptSelectRef" v-model="selected_dept_ids" size="small"
  49. style="width: 300px;" :options="deptList" :props="cascaderProps" placeholder="请选择部门"
  50. filterable clearable @change="deptChange" :disabled="!currentNode.enable"></el-cascader>
  51. <br>
  52. <div class="fontColorC">(<span style="color: red"> * </span>组织架构中,所设置的部门管理员 )</div>
  53. </el-form-item>
  54. <el-form-item label="多人时">
  55. <el-radio-group v-model="currentNode.multipleType" :disabled="!currentNode.enable">
  56. <el-radio-button label="or">任一人确认(或签)</el-radio-button>
  57. <el-radio-button label="parallel">按顺序确认(会签)</el-radio-button>
  58. <el-radio-button label="sequence">同时确认(会签)</el-radio-button>
  59. </el-radio-group>
  60. </el-form-item>
  61. <div
  62. style=" width: 100%; height: 50px; display: flex; flex-direction: column; justify-content: space-around; font-size: 14px; color: #999; padding: 0 0 20px 50px; box-sizing: border-box;">
  63. <div class="flex-box-ce">
  64. <span style="color: red;">*</span><span>会签要求所有审批人一致同意</span>
  65. </div>
  66. <div class="flex-box-ce">
  67. <span style="color: red;">*</span><span>或签只需任一审批人同意即可</span>
  68. </div>
  69. </div>
  70. <!-- <el-form-item label="允许">
  71. <el-checkbox-group v-model="currentNode.allows" :disabled="!currentNode.enable">
  72. <el-checkbox-button label="transfer">转交</el-checkbox-button>
  73. </el-checkbox-group>
  74. </el-form-item> -->
  75. </el-form>
  76. </div>
  77. <div slot="footer">
  78. <el-button type="primary" @click="submitForm" size="small">确 定</el-button>
  79. <el-button @click="handleCloseDialog" size="small">取 消</el-button>
  80. </div>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapGetters } from 'vuex';
  86. import EmployeeSelector from '@/components/EmployeeSelector'; // 选择部门组件
  87. // 引入lodash库
  88. import _ from 'lodash';
  89. export default {
  90. components: {
  91. EmployeeSelector,
  92. },
  93. model: {
  94. prop: 'resultInput',
  95. event: 'close-dialog'
  96. },
  97. props: {
  98. resultInput: {
  99. type: Boolean,
  100. default: false
  101. },
  102. dialogTitle: {
  103. type: String,
  104. default: ''
  105. },
  106. nodeType: {
  107. type: String,
  108. default: ''
  109. },
  110. formLabel: {
  111. type: String,
  112. default: ''
  113. },
  114. templateId: {
  115. type: String | Number,
  116. default: ''
  117. },
  118. indicatorId: {
  119. type: String | Number,
  120. default: ''
  121. },
  122. tagIndex: {
  123. type: String | Number,
  124. default: 0
  125. },
  126. selectNodes: {
  127. type: Array,
  128. default: () => []
  129. }
  130. },
  131. computed: {
  132. ...mapGetters(['user_info'])
  133. },
  134. data() {
  135. return {
  136. cascaderProps: {
  137. multiple: true, // 启用多选
  138. checkStrictly: true, // 父子节点不联动
  139. emitPath: false, // 选中值只返回当前节点的值
  140. },
  141. levelOptions: [
  142. {
  143. value: 1,
  144. label: '直接管理员'
  145. },
  146. {
  147. value: 2,
  148. label: '二级管理员'
  149. },
  150. {
  151. value: 3,
  152. label: '三级管理员'
  153. },
  154. {
  155. value: 4,
  156. label: '四级管理员'
  157. },
  158. {
  159. value: 5,
  160. label: '五级管理员'
  161. },
  162. {
  163. value: 6,
  164. label: '六级管理员'
  165. }
  166. ],
  167. deptList: JSON.parse(localStorage.getItem("deptList")), // 部门列表 - 树形结构
  168. dept_list: JSON.parse(localStorage.getItem("dept_list")), // 部门列表
  169. employeeMap: this.$getEmployeeMap(), // 员工列表
  170. postList: JSON.parse(localStorage.getItem("postList")), // 岗位列表
  171. selected_dept_ids: [], // 选择的部门列表
  172. selected_manager_ids: '', // 选择的管理员列表
  173. selected_post_ids: [], // 选择的岗位列表
  174. selected_employee_ids: [], // 选择的员工列表
  175. childIndex: 0,
  176. currentNode: null
  177. }
  178. },
  179. watch: {
  180. 'resultInput'(v) {
  181. if (v) this.initData()
  182. },
  183. },
  184. mounted() {
  185. this.initData();
  186. },
  187. methods: {
  188. idGeneral() {
  189. var s = [];
  190. var hexDigits = "0123456789abcdef";
  191. for (var i = 0; i < 36; i++) {
  192. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  193. }
  194. s[14] = "4"; // 代表UUID版本
  195. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // 时钟序列
  196. s[8] = s[13] = s[18] = s[23] = "-";
  197. var uuid = s.join("");
  198. return uuid;
  199. },
  200. initData() {
  201. this.selectNodes.forEach(select => {
  202. // 正在操作的节点
  203. if (select.type == this.nodeType) this.currentNode = _.cloneDeep(select)
  204. })
  205. console.log("操作节点")
  206. console.log(this.currentNode)
  207. this.currentNode.enable = false // 默认禁用
  208. this.selected_manager_ids = 1;
  209. this.selected_employee_ids = [];
  210. this.selected_post_ids = [];
  211. this.selected_dept_ids = [];
  212. this.selected_employee_ids = this.currentNode.assigneeType === 'user' ? this.currentNode.assigneeIds : [];
  213. this.selected_post_ids = this.currentNode.assigneeType === 'post' ? this.currentNode.assigneeIds : [];
  214. this.selected_dept_ids = this.currentNode.assigneeType === 'deptLeader' ? this.currentNode.assigneeIds : [];
  215. },
  216. // 选择管理员
  217. changeManagerIds(v) {
  218. this.currentNode.leaderLevel = v
  219. },
  220. // 选择员工
  221. changeEmployeeIds(v) {
  222. if (v && v.length > 0) {
  223. this.currentNode.assigneeIds = v
  224. }
  225. },
  226. // 选择岗位
  227. changePostIds(v) {
  228. if (v && v.length > 0) {
  229. this.currentNode.assigneeIds = v
  230. }
  231. },
  232. // 选择部门
  233. deptChange(val) {
  234. if (val && val.length > 0) {
  235. // 获取当前选中的节点
  236. const checkedNodes = this.$refs.deptSelectRef.getCheckedNodes();
  237. this.selected_dept_ids = checkedNodes.map((node) => node.value);
  238. this.currentNode.assigneeIds = this.selected_dept_ids
  239. this.currentNode.assigneeIds = Array.from(new Set(this.currentNode.assigneeIds)); // 去重
  240. }
  241. },
  242. handleCloseDialog() {
  243. this.currentNode = null
  244. this.selected_manager_ids = 1;
  245. this.selected_employee_ids = [];
  246. this.selected_post_ids = [];
  247. this.selected_dept_ids = [];
  248. this.$emit('close-dialog', false)
  249. },
  250. submitForm() {
  251. // 验证表单数据
  252. this.currentNode.assigneeIds = []
  253. // 回显选中的管理者
  254. if (this.currentNode.assigneeType == 'leader') {
  255. if (this.selected_manager_ids) this.currentNode.leaderLevel = this.selected_manager_ids
  256. else return this.$message.error("请选择管理员")
  257. }
  258. // 回显选中的被考核人
  259. if (this.currentNode.assigneeType == 'self') {
  260. this.currentNode.assigneeIds.push(this.user_info.id);
  261. }
  262. // 回显选中的岗位
  263. if (this.currentNode.assigneeType == 'post') {
  264. if (this.selected_post_ids && this.selected_post_ids.length > 0)
  265. this.selected_post_ids.forEach(postId => {
  266. this.currentNode.assigneeIds.push(postId);
  267. })
  268. else return this.$message.error("请选择岗位")
  269. }
  270. // 回显选中的指定人员
  271. if (this.currentNode.assigneeType == 'user') {
  272. if (this.selected_employee_ids && this.selected_employee_ids.length > 0)
  273. this.selected_employee_ids.forEach(employeeId => {
  274. this.currentNode.assigneeIds.push(employeeId);
  275. })
  276. else return this.$message.error("请选择指定人员")
  277. }
  278. // 回显选中的部门列表
  279. if (this.currentNode.assigneeType == 'deptLeader') {
  280. if (this.selected_dept_ids && this.selected_dept_ids.length > 0)
  281. this.selected_dept_ids.forEach(dept_id => {
  282. this.currentNode.assigneeIds.push(dept_id);
  283. })
  284. else return this.$message.error("请选择部门")
  285. }
  286. // 去重
  287. this.currentNode.assigneeIds = Array.from(new Set(this.currentNode.assigneeIds))
  288. let nodes = []
  289. this.selectNodes.forEach(select => {
  290. // 正在操作的节点
  291. if (select.type == this.nodeType) {
  292. select = this.currentNode
  293. }
  294. nodes.push(select)
  295. })
  296. let data = {
  297. indicatorId: this.indicatorId, // 指标ID
  298. nodes
  299. }
  300. this.$emit("onConfirm", data);
  301. this.handleCloseDialog();
  302. },
  303. handleFormData() {
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. </style>