accountsEdit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="pageBody">
  3. <div class="topPart">
  4. <div class="title">
  5. <div class="tltleLeft">编辑岗位</div>
  6. <!-- <div class="isUsed">
  7. 是否启用
  8. <el-radio
  9. v-model="FormData.isUsed"
  10. v-if="FormData.isUsed == 1 || form.isUsed == 3"
  11. :label="1"
  12. >是</el-radio
  13. >
  14. <el-radio v-model="FormData.isUsed" v-if="FormData.isUsed == 2" :label="2"
  15. >是</el-radio
  16. >
  17. <el-radio v-model="FormData.isUsed" :label="3">否</el-radio>
  18. </div> -->
  19. <div>
  20. <!-- <button type="submmit" class="delBtn" @click="delate">删除</button> -->
  21. <button type="submmit" class="saveBtn" @click="saveJob()">
  22. 保存
  23. </button>
  24. </div>
  25. </div>
  26. <div class="titleContent">
  27. <el-form ref="form" :model="FormData" label-width="80px">
  28. <el-row :gutter="40">
  29. <el-col :span="5">
  30. <el-form-item label="岗位名称" prop="name">
  31. <el-input
  32. v-model="FormData.JobName"
  33. maxlength="32"
  34. placeholder="请输入岗位名称"
  35. size="small"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="10">
  40. <el-form-item label="描述" prop="diesc">
  41. <el-input
  42. v-model="FormData.JobDesc"
  43. maxlength="128"
  44. placeholder="描述内容"
  45. size="small"
  46. ></el-input>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. </el-form>
  51. </div>
  52. </div>
  53. <div class="content">
  54. <el-row :gutter="25">
  55. <el-col :span="24" v-if="systemSet.UserOfficerMulti != 0">
  56. <div class="part">
  57. <Organization
  58. title="所属组织"
  59. :data="dataList"
  60. :defaultProps="defaultProps"
  61. :nodekey="'Organid'"
  62. @getCheckedData="getOrganTreeData"
  63. :checkedKeys="checkedIdList"
  64. />
  65. </div>
  66. </el-col>
  67. <el-col :span="8" v-if="systemSet.UserOfficerMulti === 0">
  68. <div class="part">
  69. <Organization
  70. title="所属组织"
  71. :data="originData"
  72. :defaultProps="defaultProps"
  73. :nodekey="'Organid'"
  74. :checkedKeys="checkedIdList"
  75. />
  76. </div>
  77. </el-col>
  78. <el-col
  79. :span="8"
  80. v-if="systemSet.OpenRole === 0 && systemSet.UserOfficerMulti === 0"
  81. >
  82. <div class="part">
  83. <Permissiontree
  84. @getTreeData="getAuthTreeData"
  85. :checkedKeys="checkedAuthKeys"
  86. :queryType="queryType"
  87. :queryId="originId"
  88. title="权限树"
  89. />
  90. </div>
  91. </el-col>
  92. <el-col
  93. :span="8"
  94. v-if="systemSet.OpenRole === 0 && systemSet.UserOfficerMulti === 0"
  95. >
  96. <div class="part">
  97. <Rulesofcompetency title="权限规则" />
  98. </div>
  99. </el-col>
  100. <el-col
  101. :span="8"
  102. v-if="systemSet.OpenRole != 0 && systemSet.UserOfficerMulti === 0"
  103. >
  104. <div class="part">
  105. <rolelist
  106. title="角色列表"
  107. @checkChange="checkRoleChange"
  108. :dataList="originRoleList"
  109. :checkBoxList="checkedRoleKeys"
  110. @checkClick="roleClick"
  111. :number="8"
  112. />
  113. </div>
  114. </el-col>
  115. <el-col
  116. :span="8"
  117. v-if="systemSet.OpenRole != 0 && systemSet.UserOfficerMulti === 0"
  118. >
  119. <div class="part">
  120. <permissionlist
  121. title="权限列表"
  122. :RoleList="powerList"
  123. :check="true"
  124. class="hucPower"
  125. @Competen="Competen"
  126. />
  127. </div>
  128. </el-col>
  129. </el-row>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import Permissiontree from "@/components/permissiontree/index.vue";
  135. import Rulesofcompetency from "@/components/rulesofcompetency/index.vue";
  136. import Organization from "@/components/organization/index.vue";
  137. import rolelist from "@/components/rolelist/index.vue";
  138. import permissionlist from "@/components/permissionlist/index.vue";
  139. import treeData from "../minixs/treeData";
  140. import roleData from "../minixs/roleData";
  141. import { GetJobDetails, EditJob } from "@/api/jobApi";
  142. import { newOrganall } from "@/api/postInterface";
  143. import { RoleAuths } from "@/api/apiAuthority";
  144. export default {
  145. data() {
  146. return {
  147. queryType: "origin",
  148. JobId: 0, //当前岗位ID
  149. systemSet: null, //系统设置
  150. FormData: {
  151. JobName: "",
  152. AuthList: [],
  153. JobDesc: "",
  154. JobId: 0,
  155. JobName: "",
  156. OrganId: 0,
  157. RoleList: [],
  158. },
  159. rules: {
  160. JobName: [
  161. { required: true, message: "请输入岗位名称", trigger: "blur" },
  162. {
  163. min: 1,
  164. max: 16,
  165. message: "长度在 1 到 16 个字符",
  166. trigger: "blur",
  167. },
  168. ],
  169. },
  170. defaultProps: {
  171. children: "children",
  172. label: "OrganName",
  173. },
  174. listData: [], //上级组织树
  175. originId: "-1", //所属组织ID
  176. originData: [], //所属组织详情
  177. checkedIdList: [], //选中组织树
  178. AuthList: [], //选中权限(包含规则组)
  179. RoleList: [], //选中角色组
  180. checkedAuthKeys: [],
  181. checkedRoleKeys: [],
  182. originRoleList: [], //所属组织角色列表
  183. powerList:[],//角色权限列表
  184. };
  185. },
  186. mixins: [treeData, roleData],
  187. watch: {
  188. arrs: {
  189. handler(arr) {
  190. arr.forEach((item) => {
  191. item.name = item.RoleName;
  192. if (
  193. item.IsSelected == 1 &&
  194. _.indexOf(this.originRoleList, item) == -1
  195. ) {
  196. this.originRoleList.push(item);
  197. }
  198. });
  199. this.checkedRoleKeys = [];
  200. this.RoleList.forEach((item) => {
  201. this.originRoleList.forEach((value, index) => {
  202. if (item.RoleId == value.RoleId) {
  203. this.checkedRoleKeys.push(index);
  204. }
  205. });
  206. });
  207. },
  208. deep: true,
  209. },
  210. },
  211. created: function () {
  212. const systemData = this.$store.state.app.systemSet;
  213. if (typeof systemData == "string") {
  214. this.systemSet = JSON.parse(systemData);
  215. } else {
  216. this.systemSet = systemData;
  217. }
  218. this.JobId = this.$route.query.JobId;
  219. this.getJobDetails();
  220. },
  221. components: {
  222. Organization,
  223. Permissiontree,
  224. Rulesofcompetency,
  225. rolelist,
  226. permissionlist,
  227. },
  228. methods: {
  229. //获取岗位详情
  230. getJobDetails() {
  231. try {
  232. let data = {
  233. JobId: this.JobId,
  234. };
  235. GetJobDetails(data).then((result) => {
  236. if (result.code === 0) {
  237. this.FormData = _.cloneDeep(result.returnData);
  238. this.originId = result.returnData.OrganId+"";
  239. this.AuthList = _.cloneDeep(result.returnData.AuthList);
  240. this.$store.state.auth.authList = _.cloneDeep(
  241. result.returnData.AuthList
  242. );
  243. let list = _.cloneDeep(result.returnData.RoleList);
  244. if(list){
  245. list.forEach((item, index) => {
  246. if (item.IsSelected == 1) {
  247. this.RoleList.push(item);
  248. }
  249. });
  250. }
  251. if (this.AuthList) {
  252. this.AuthList.forEach((item) => {
  253. this.checkedAuthKeys.push(item.AuthId);
  254. });
  255. }
  256. this.checkedIdList.push(result.returnData.OrganId);
  257. this.getOrganDetails();
  258. this.getRoleByOrgan(this.originId);
  259. }
  260. });
  261. } catch (error) {
  262. console.log("GetJobDetails");
  263. console.log(error);
  264. }
  265. },
  266. //获取所属组织详情
  267. getOrganDetails() {
  268. try {
  269. let data = {
  270. OrganId: this.originId,
  271. };
  272. newOrganall(data).then((result) => {
  273. if (result.code == 0) {
  274. this.originData = [];
  275. this.originData.push(result.returnData);
  276. }
  277. });
  278. } catch (error) {
  279. console.log("newOrganall");
  280. console.log(error);
  281. }
  282. },
  283. //获取当权选中权限树
  284. getAuthTreeData(data) {
  285. this.checkedAuthTreeList = _.cloneDeep(data);
  286. },
  287. //获取组织树点击
  288. getOrganTreeData(data) {
  289. console.log(data);
  290. },
  291. //角色选中后
  292. checkRoleChange(data) {
  293. this.RoleList = [];
  294. data.forEach((item) => {
  295. this.originRoleList[item].IsSelected = 1;
  296. this.RoleList.push(this.originRoleList[item]);
  297. });
  298. },
  299. //点击角色后
  300. roleClick(data) {
  301. try {
  302. let params = {
  303. RoleId: data.RoleId,
  304. };
  305. RoleAuths(params).then((result) => {
  306. this.powerList = result.returnData;
  307. });
  308. } catch (error) {
  309. console.log("RoleAuths");
  310. console.log(error);
  311. }
  312. },
  313. //保存
  314. saveJob() {
  315. try {
  316. let arr = _.cloneDeep(this.checkedAuthTreeList);
  317. let authArrs = _.cloneDeep(this.$store.state.auth.authArrs);
  318. if (arr) {
  319. this.AuthList = [];
  320. arr.forEach((item) => {
  321. this.AuthList.push(item.AuthList);
  322. });
  323. this.AuthList.forEach((item, index) => {
  324. authArrs.forEach((item2) => {
  325. if (item.AuthId == item2.AuthId) {
  326. this.AuthList[index] = item2.AuthList;
  327. }
  328. });
  329. });
  330. }
  331. this.FormData.AuthList = this.AuthList;
  332. this.FormData.RoleList = this.RoleList;
  333. let data = _.cloneDeep(this.FormData);
  334. EditJob(data).then((result) => {
  335. if (result.code == 0) {
  336. this.$message.success(result.message);
  337. this.$router.push("/jobs");
  338. }
  339. });
  340. } catch (error) {
  341. console.log("EditJob");
  342. console.log(error);
  343. }
  344. },
  345. //查看权限列表明细
  346. Competen(data) {
  347. this.$emit("Competen", data);
  348. },
  349. //获取指定数据
  350. decompose(data, id) {
  351. for (let i = 0; i < data.length; i++) {
  352. if (data[i].GroupId == id) {
  353. this.dataObj = data[i];
  354. delete this.dataObj.children;
  355. this.dataObj = [this.dataObj];
  356. } else if (data[i].children && data[i].children.length > 0) {
  357. this.decompose(data[i].children, id);
  358. }
  359. }
  360. },
  361. },
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. .pageBody {
  366. width: 100%;
  367. height: calc(100vh - 178px);
  368. padding: 0 64px;
  369. padding-top: 32px;
  370. .topPart {
  371. box-sizing: border-box;
  372. width: 100%;
  373. height: 184px;
  374. padding: 32px;
  375. background: #ffffff;
  376. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  377. border-radius: 16px;
  378. .title {
  379. display: flex;
  380. justify-content: space-between;
  381. flex-direction: row;
  382. position: relative;
  383. .isUsed {
  384. position: absolute;
  385. left: 194px;
  386. top: 6px;
  387. }
  388. .tltleLeft {
  389. font-size: 24px;
  390. font-weight: bold;
  391. color: #303133;
  392. }
  393. .saveBtn {
  394. width: 80px;
  395. height: 40px;
  396. background: linear-gradient(0deg, #777dba, #6983be);
  397. border-radius: 6px;
  398. color: #fff;
  399. border: none;
  400. }
  401. .delBtn {
  402. width: 80px;
  403. height: 40px;
  404. background: #f56c6c;
  405. border-radius: 6px;
  406. color: #fff;
  407. border: none;
  408. margin-right: 24px;
  409. }
  410. }
  411. .titleContent {
  412. width: 100%;
  413. padding-top: 35px;
  414. box-sizing: border-box;
  415. .resetPass {
  416. background: #6e81bc;
  417. color: #fff;
  418. margin-top: 4px;
  419. margin-left: -25px;
  420. }
  421. }
  422. }
  423. .content {
  424. width: 100%;
  425. height: calc(100% - 184px);
  426. padding-top: 24px;
  427. box-sizing: border-box;
  428. .part {
  429. width: 100%;
  430. height: 720px;
  431. background: #ffffff;
  432. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  433. border-radius: 16px;
  434. }
  435. }
  436. }
  437. </style>