PerResultInputSelectorOnly.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <el-dialog
  3. :visible.sync="innerVisible"
  4. @close="handleClose"
  5. @open="initData"
  6. @closed="dataReset"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. center
  10. title="结果录入节点配置"
  11. width="600px"
  12. >
  13. <el-form v-if="currentNode" label-width="200">
  14. <el-form-item label="启用">
  15. <el-switch
  16. v-model="currentNode.enable"
  17. />
  18. </el-form-item>
  19. <el-form-item label="录入人">
  20. <el-radio-group
  21. v-model="currentNode.assigneeType"
  22. :disabled="!currentNode.enable"
  23. @change="onAssigneeTypeChange"
  24. >
  25. <el-radio-button label="leader">组织管理员</el-radio-button>
  26. <el-radio-button label="user">指定人员</el-radio-button>
  27. <el-radio-button label="self">被考核人</el-radio-button>
  28. <el-radio-button label="post">岗位</el-radio-button>
  29. <el-radio-button label="deptLeader">部门负责人</el-radio-button>
  30. </el-radio-group>
  31. </el-form-item>
  32. <el-form-item label="">
  33. <template v-if="currentNode.assigneeType === 'leader'">
  34. <el-select
  35. v-model="currentNode.leaderLevel"
  36. placeholder="请选择管理员"
  37. :disabled="!currentNode.enable"
  38. filterable
  39. style="width: 300px;"
  40. key="leader"
  41. @change="onOrgManagerChange"
  42. >
  43. <el-option
  44. v-for="item in levelOptions"
  45. :key="item.value"
  46. :label="item.label"
  47. :value="item.value"
  48. style="width: 300px;"
  49. />
  50. </el-select>
  51. </template>
  52. <template v-if="currentNode.assigneeType === 'user'">
  53. <el-select
  54. v-model="userSelected"
  55. placeholder="请选择指定人员"
  56. multiple
  57. :disabled="!currentNode.enable"
  58. filterable
  59. style="width: 300px;"
  60. key="user"
  61. @change="onUserChange"
  62. >
  63. <el-option
  64. v-for="item in employees"
  65. :key="item.id"
  66. :label="item.name"
  67. :value="item.id"
  68. style="width: 300px;"
  69. />
  70. </el-select>
  71. </template>
  72. <template v-if="currentNode.assigneeType === 'post'">
  73. <el-select
  74. v-model="postSelected"
  75. placeholder="请选择岗位"
  76. multiple
  77. :disabled="!currentNode.enable"
  78. filterable
  79. style="width: 300px;"
  80. key="post"
  81. @change="onPostChange"
  82. >
  83. <el-option
  84. v-for="item in postList"
  85. :key="item.id"
  86. :label="item.name"
  87. :value="item.id"
  88. style="width: 300px;"
  89. />
  90. </el-select>
  91. </template>
  92. <template v-if="currentNode.assigneeType === 'deptLeader'">
  93. <el-select
  94. v-model="deptSelected"
  95. placeholder="请选择部门"
  96. multiple
  97. :disabled="!currentNode.enable"
  98. filterable
  99. style="width: 300px;"
  100. key="deptLeader"
  101. @change="onDeptChange"
  102. >
  103. <el-option
  104. v-for="item in deptList"
  105. :key="item.id"
  106. :label="item.name"
  107. :value="item.id"
  108. style="width: 300px;"
  109. />
  110. </el-select>
  111. </template>
  112. </el-form-item>
  113. <el-form-item label="多人时">
  114. <el-radio-group
  115. v-model="currentNode.multipleType"
  116. :disabled="!currentNode.enable"
  117. >
  118. <el-radio-button label="or">任一人确认(或签)</el-radio-button>
  119. <el-radio-button label="parallel">按顺序确认(会签)</el-radio-button>
  120. <el-radio-button label="sequence">同时确认(会签)</el-radio-button>
  121. </el-radio-group>
  122. </el-form-item>
  123. <el-form-item label="允许">
  124. <el-checkbox-group
  125. v-model="currentNode.allows"
  126. :disabled="!currentNode.enable"
  127. >
  128. <el-checkbox-button label="transfer">转交</el-checkbox-button>
  129. </el-checkbox-group>
  130. </el-form-item>
  131. </el-form>
  132. <template #footer>
  133. <el-row type="flex" justify="end">
  134. <el-col align="end">
  135. <el-button
  136. type="primary"
  137. @click="onConfirm"
  138. >
  139. 确认
  140. </el-button>
  141. </el-col>
  142. </el-row>
  143. </template>
  144. </el-dialog>
  145. </template>
  146. <script>
  147. import Template from "../../examine/components/Template.vue";
  148. export default {
  149. name: "PerResultInputSelectorOnly",
  150. components: {Template},
  151. props: {
  152. showVisible: {
  153. type: Boolean,
  154. default: false
  155. },
  156. },
  157. data(){
  158. return {
  159. userInfo: this.$userInfo(),
  160. currentNode: null,
  161. innerVisible: this.showVisible,
  162. loading:false,
  163. employees:[],
  164. postList:[],
  165. deptList:[],
  166. userSelected:[],
  167. postSelected:[],
  168. deptSelected:[],
  169. assigneeMap:{
  170. leader:'组织管理员',
  171. user:'指定人员',
  172. self:'被考核人',
  173. post:'岗位',
  174. deptLeader:'部门负责人',
  175. },
  176. levelOptions: [
  177. {
  178. value: 1,
  179. label: '直接管理员'
  180. },
  181. {
  182. value: 2,
  183. label: '二级管理员'
  184. },
  185. {
  186. value: 3,
  187. label: '三级管理员'
  188. },
  189. {
  190. value: 4,
  191. label: '四级管理员'
  192. },
  193. {
  194. value: 5,
  195. label: '五级管理员'
  196. },
  197. {
  198. value: 6,
  199. label: '六级管理员'
  200. }
  201. ]
  202. }
  203. },
  204. computed:{
  205. employeeMap(){
  206. const map = {};
  207. this.employees.forEach(e => {
  208. if (!map[e.id]) map[e.id] = e.name;
  209. });
  210. return map;
  211. },
  212. postMap(){
  213. const map = {};
  214. this.postList.forEach(e => {
  215. if (!map[e.id]) map[e.id] = e.name;
  216. });
  217. return map;
  218. },
  219. deptMap(){
  220. const map = {};
  221. this.deptList.forEach(e => {
  222. if (!map[e.id]) map[e.id] = e.name;
  223. });
  224. return map;
  225. },
  226. },
  227. watch:{
  228. showVisible(val){
  229. this.innerVisible = val;
  230. },
  231. },
  232. methods: {
  233. idGeneral(){
  234. return Date.now() + Math.floor(Math.random() * 10000);
  235. },
  236. defaultNode(){
  237. const node = JSON.parse("{\"id\":\"RI_1907236768800382977\",\"type\":\"resultInput\",\"enable\":true,\"assigneeType\":\"self\",\"leaderLevel\":1,\"assigneeIds\":[],\"multipleType\":\"or\",\"allows\":[\"transfer\"],\"weight\":0,\"children\":[]}");
  238. node.id = "RI_" + this.idGeneral();
  239. return node;
  240. },
  241. matchErrMsg(err){
  242. return err.toString().replace(/[(Error: )]/g,'');
  243. },
  244. handleClose(){
  245. this.$emit('update:showVisible',false);
  246. },
  247. dataReset(){
  248. this.currentNode = null;
  249. this.userSelected = [];
  250. this.postSelected = [];
  251. this.deptSelected = [];
  252. },
  253. initData(){
  254. if (this.loading) return;
  255. this.dataReset();
  256. this.loading = true;
  257. let result = true;
  258. Promise.all([
  259. this.$axiosUser('get', '/api/pro/employee/index', {page:0,page_size:10,status:1}, 'v2'),
  260. this.$axiosUser('get','/org/post'),
  261. this.$axiosUser('get', `/org/departments/${this.userInfo.site_id}`)
  262. ])
  263. .then(([employeeRes,postRes,deptRes]) => {
  264. if (employeeRes.data.code !== 1) throw new Error(employeeRes.data.msg);
  265. if (postRes.data.code !== 1) throw new Error(postRes.data.message);
  266. if (deptRes.data.code !== 1) throw new Error(deptRes.data.message);
  267. this.employees = employeeRes.data.data.list
  268. .filter(e => e.account_id && e.account_id > 0)
  269. .map(e => {
  270. return {
  271. id:e.id,
  272. name:e.name,
  273. }
  274. });
  275. this.postList = postRes.data.data.map(item => {
  276. return {
  277. id: item.id,
  278. name: item.name,
  279. }
  280. });
  281. this.deptList = deptRes.data.data.list.map(item => {
  282. return {
  283. id: item.id,
  284. name: item.name,
  285. }
  286. });
  287. this.currentNode = this.defaultNode();
  288. switch (this.currentNode.assigneeType){
  289. case 'user':
  290. this.userSelected = this.currentNode.assigneeIds;
  291. break;
  292. case 'post':
  293. this.postSelected = this.currentNode.assigneeIds;
  294. break;
  295. case 'deptLeader':
  296. this.deptSelected = this.currentNode.assigneeIds;
  297. break;
  298. }
  299. })
  300. .catch(err => {
  301. this.$message.error(this.matchErrMsg(err));
  302. result = false;
  303. })
  304. .finally(() => {
  305. this.loading = false;
  306. if (!result) this.handleClose();
  307. })
  308. },
  309. onAssigneeTypeChange(v){
  310. this.currentNode.assigneeIds = [];
  311. this.currentNode.leaderLevel = 1;
  312. this.userSelected = [];
  313. this.postSelected = [];
  314. this.deptSelected = [];
  315. },
  316. onOrgManagerChange(v){
  317. this.currentNode.assigneeIds = [];
  318. this.currentNode.leaderLevel = v;
  319. this.userSelected = [];
  320. this.postSelected = [];
  321. this.deptSelected = [];
  322. },
  323. onUserChange(v){
  324. this.currentNode.assigneeIds = [...v];
  325. this.currentNode.leaderLevel = 1;
  326. this.userSelected = v;
  327. this.postSelected = [];
  328. this.deptSelected = [];
  329. },
  330. onPostChange(v){
  331. this.currentNode.assigneeIds = [...v];
  332. this.currentNode.leaderLevel = 1;
  333. this.userSelected = [];
  334. this.postSelected = v;
  335. this.deptSelected = [];
  336. },
  337. onDeptChange(v){
  338. this.currentNode.assigneeIds = [...v];
  339. this.currentNode.leaderLevel = 1;
  340. this.userSelected = [];
  341. this.postSelected = [];
  342. this.deptSelected = v;
  343. },
  344. onConfirm(){
  345. this.$emit('confirm',this.currentNode);
  346. this.handleClose();
  347. },
  348. }
  349. }
  350. </script>
  351. <style scoped lang="scss">
  352. .handler-list {
  353. width: 500px;
  354. margin: 0 auto 16px auto;
  355. border-radius: 6px;
  356. border: 1px solid #d7dae2;
  357. padding: 10px 0 0 10px;
  358. box-sizing: border-box;
  359. display: flex;
  360. flex-wrap: wrap;
  361. .el-tag {
  362. margin: 0 10px 10px 0;
  363. cursor: pointer;
  364. }
  365. }
  366. </style>