You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

447 lines
14 KiB

3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
  1. <template>
  2. <div>
  3. <el-card style="height: 600px">
  4. <!-- <el-button type="primary" @click="addorginiztiom">新增组织</el-button> -->
  5. <div class="publicfontsize">科室设置</div>
  6. <div class="allC">
  7. <!-- <i
  8. class="el-icon-link"
  9. v-if="natureoptions.length == '0' ? false : true"
  10. ></i
  11. ><span>组织架构</span> -->
  12. <div
  13. v-if="natureoptions.length == '0' ? true : false"
  14. @click="append(node, data)"
  15. >
  16. <i class="el-icon-link" @click="append"></i><span> 添加组织</span>
  17. </div>
  18. <el-tree
  19. :default-expand-all="true"
  20. :expand-on-click-node="false"
  21. :data="natureoptions"
  22. :props="defaultProps"
  23. :show-checkbox="false"
  24. ref="tree"
  25. node-key="id"
  26. style="width: 30%; margin-top: 20px"
  27. @check="check"
  28. >
  29. <span slot-scope="{ node, data }">
  30. <span>{{ node.label }}</span>
  31. <span>
  32. <!-- <i
  33. v-if="data.id !== 0"
  34. class="el-icon-plus"
  35. @click="append(node, data)"
  36. style="font-size:15px"
  37. ></i> -->
  38. <el-button
  39. type="primary"
  40. size="small"
  41. style="padding: 3px; font-size: 15px; margin-left: 5%"
  42. @click="() => addorginiztiom(node, data)"
  43. >新增同级</el-button
  44. >
  45. <el-button
  46. type="primary"
  47. size="mini"
  48. style="padding: 3px; font-size: 15px"
  49. @click="append(node, data)"
  50. >新增子级</el-button
  51. >
  52. <!-- <i class="el-icon-delete" @click="() => deleates(node, data)" style="font-size:15px"></i> -->
  53. <el-button
  54. type="danger"
  55. size="mini"
  56. style="padding: 3px; font-size: 15px"
  57. @click="() => deleates(node, data)"
  58. >删除</el-button
  59. >
  60. <!-- <i class="el-icon-edit" @click="() => rena(node, data)" style="font-size:15px">编辑</i> -->
  61. <el-button
  62. type="primary"
  63. size="small"
  64. style="padding: 3px; font-size: 15px"
  65. @click="() => rena(node, data)"
  66. >编辑</el-button
  67. >
  68. </span>
  69. </span>
  70. </el-tree>
  71. <!-- 弹框 -->
  72. <!-- <el-button type="primary" @click="addorginiztiom" style="height: 40px"
  73. >新增组织</el-button
  74. > -->
  75. </div>
  76. <!-- 新增组织弹框 -->
  77. <el-dialog
  78. :title="title == 2 ? '修改组织' : '新增组织'"
  79. :visible.sync="dialogVisible"
  80. width="50%"
  81. @close="closethiebox"
  82. :close-on-click-modal="false"
  83. >
  84. <div v-if="title == 2">
  85. 当前选中的科室<span
  86. style="margin-left: 20px; font-size: 18px; margin-top: -20px"
  87. >{{ departmentnames }}</span
  88. >
  89. </div>
  90. <div v-if="title == 2">
  91. <span>上级部门</span>
  92. <el-cascader
  93. v-model="departmentname"
  94. ref="depref"
  95. @change="cascaderchang"
  96. :show-all-levels="false"
  97. :options="selecttable"
  98. :props="{
  99. checkStrictly: true,
  100. children: 'treeChildren',
  101. label: 'displayName',
  102. value: 'displayName',
  103. }"
  104. clearable
  105. ></el-cascader>
  106. <!-- <el-tree
  107. :data="title == 1 ? treedata : selecttable"
  108. :props="defaultProp"
  109. @node-click="treeclick"
  110. >
  111. </el-tree> -->
  112. </div>
  113. <el-row>
  114. <el-col :span="8" style="line-height: 40px">
  115. 是否为体检中心
  116. <el-radio-group v-model="form.isPeis">
  117. <el-radio label="Y"></el-radio>
  118. <el-radio label="N"></el-radio>
  119. </el-radio-group>
  120. <!-- <el-radio v-model="form.isPeis" label="Y"></el-radio>
  121. <el-radio v-model="form.isPeis" label="N"></el-radio> -->
  122. </el-col>
  123. <el-col :span="12">
  124. <el-form :model="form">
  125. <el-form-item label="名称" label-width="80px">
  126. <el-input v-model="form.displayName"></el-input>
  127. </el-form-item>
  128. </el-form>
  129. </el-col>
  130. </el-row>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="dialogVisible = false"> </el-button>
  133. <el-button type="primary" @click="organizationtreeaddoredit"
  134. > </el-button
  135. >
  136. </span>
  137. </el-dialog>
  138. </el-card>
  139. </div>
  140. </template>
  141. <script>
  142. import {
  143. organizationtree,
  144. organizationcaeatre,
  145. deleteschema,
  146. modifyedit,
  147. } from "../../request/ruquset";
  148. import { postapi, putapi, getapi } from "@/api/api";
  149. export default {
  150. data() {
  151. return {
  152. showcheckbox: false,
  153. defaultKeys: [],
  154. selecttable: [], //科室的选择选中
  155. form: {
  156. parentId: "",
  157. displayName: "",
  158. isPeis: "N",
  159. departmentname: "",
  160. },
  161. title: 1,
  162. dialogVisible: false,
  163. natureoptions: [],
  164. defaultProp: {
  165. children: "treeChildren",
  166. label: "displayName",
  167. value: "displayName",
  168. },
  169. defaultProps: {
  170. children: "treeChildren",
  171. label: "displayName",
  172. },
  173. checked: false,
  174. parent: 1,
  175. treedata: [],
  176. departmentname: "", //科室名称
  177. departmentnames: "",
  178. };
  179. },
  180. mounted() {
  181. this.getonorganization();
  182. },
  183. methods: {
  184. cascaderchang(v) {
  185. console.log(this.departmentname);
  186. this.departmentnames = v[v.length - 1];
  187. // localStorage.setItem("departmentname", v[v.length - 1]);
  188. // console.log(v[v.length-1]);
  189. // v.forEach((item) => {
  190. // this.departmentname = item;
  191. // });
  192. // let a=this.depref.value.togglePoppervisible()
  193. // console.log(a);
  194. },
  195. //选中的组织
  196. treeclick(data) {
  197. this.departmentname = data.displayName;
  198. console.log(data);
  199. },
  200. //close弹框关闭事件
  201. closethiebox() {
  202. this.departmentname = "";
  203. },
  204. //关闭弹框
  205. closethebulletbox() {
  206. this.dialogVisible = false;
  207. this.form = {};
  208. this.form.isPeis = "N";
  209. },
  210. //确定新增或者编辑
  211. organizationtreeaddoredit() {
  212. if (this.title == 1) {
  213. if (this.form.displayName != "") {
  214. console.log(this.form.parentId);
  215. if (this.form.parentId == "") {
  216. postapi("/api/app/organization-units/creatre", {
  217. displayName: this.form.displayName,
  218. isPeis: this.form.isPeis,
  219. }).then((res) => {
  220. if (res.code == 0) {
  221. this.$message.success("新增成功");
  222. this.dialogVisible = false;
  223. this.form.displayName = "";
  224. this.getonorganization();
  225. }
  226. });
  227. } else {
  228. postapi("/api/app/organization-units/creatre", {
  229. displayName: this.form.displayName,
  230. isPeis: this.form.isPeis,
  231. parentId: this.form.parentId,
  232. }).then((res) => {
  233. if (res.code == 0) {
  234. this.$message.success("新增成功11");
  235. this.dialogVisible = false;
  236. this.form.displayName = "";
  237. this.getonorganization();
  238. }
  239. });
  240. }
  241. } else {
  242. this.$message.warning("请输入名称");
  243. }
  244. } else if (this.title == 2) {
  245. putapi(
  246. `/api/app/organization-units?Id=${this.form.id}&DisplayName=${this.form.displayName}&IsPeis=${this.form.isPeis}`
  247. ).then((res) => {
  248. if (res.code == 0) {
  249. this.$message.success("编辑成功");
  250. this.dialogVisible = false;
  251. this.getonorganization();
  252. }
  253. });
  254. } else if (this.title == 3) {
  255. if (this.form.displayName == "") {
  256. this.$message.warning("请输入名称");
  257. } else {
  258. postapi("/api/app/organization-units/creatre", {
  259. displayName: this.form.displayName,
  260. isPeis: this.form.isPeis,
  261. parentId: this.form.parentId,
  262. }).then((res) => {
  263. this.$message.success("新增成功");
  264. this.dialogVisible = false;
  265. // this.form = {};
  266. this.form.displayName = "";
  267. this.form.isPeis = "N";
  268. this.getonorganization();
  269. });
  270. }
  271. }
  272. },
  273. check(data) {
  274. console.log(data);
  275. localStorage.setItem("dataidkes", data.id);
  276. // this.$refs.tree.getCheckedKeys()
  277. },
  278. getonorganization() {
  279. organizationtree().then((res) => {
  280. this.natureoptions = res.data;
  281. console.log(res);
  282. });
  283. },
  284. //添加父级组织
  285. addorginiztiom(node, data) {
  286. // this.$prompt("组织名称", "新增组织", {
  287. // confirmButtonText: "确定",
  288. // cancelButtonText: "取消",
  289. // inputPattern: /^[\u4e00-\u9fa5]{0,}$/, //匹配全中文
  290. // inputErrorMessage: "请输入中文", //不符合正则匹配的提示语句
  291. // }).then(({ value }) => {
  292. // //parentId:data.id
  293. // organizationcaeatre({ displayName: value }).then((res) => {
  294. // this.getonorganization();
  295. // this.$message.success("新增成功");
  296. // });
  297. // });
  298. getapi("/api/app/organization-units/by-code-all").then((res) => {
  299. this.treedata = res.data;
  300. console.log(res);
  301. });
  302. this.selecttable = [];
  303. this.dialogVisible = true;
  304. this.title = 1;
  305. if (this.title == 1) {
  306. this.form.parentId = data.parentId;
  307. console.log(this.form.parentId);
  308. }
  309. // this.form.parentId = "";
  310. console.log(this.form);
  311. this.form.displayName = "";
  312. },
  313. //新增组织组织
  314. append(node, data) {
  315. this.form.displayName = "";
  316. this.title = 3;
  317. if (this.title == 3) {
  318. this.dialogVisible = true;
  319. this.form.parentId = data.id;
  320. console.log(this.form.parentId);
  321. console.log(this.form);
  322. }
  323. // if(this.natureoptions)
  324. // console.log(node, data);
  325. // if (this.natureoptions.length == 0) {
  326. // this.$prompt("组织名称", "增加组织", {
  327. // confirmButtonText: "确定",
  328. // cancelButtonText: "取消",
  329. // inputPattern: /^[\u4e00-\u9fa5]{0,}$/, //匹配全中文
  330. // inputErrorMessage: "请输入中文", //不符合正则匹配的提示语句
  331. // }).then(({ value }) => {
  332. // //parentId:data.id
  333. // organizationcaeatre({ displayName: value }).then((res) => {
  334. // this.getonorganization();
  335. // this.$message.success("新增成功");
  336. // });
  337. // });
  338. // } else {
  339. // this.$prompt("组织名称", "增加组织", {
  340. // confirmButtonText: "确定",
  341. // cancelButtonText: "取消",
  342. // inputPattern: /^[\u4e00-\u9fa5]{0,}$/, //匹配全中文
  343. // inputErrorMessage: "请输入中文", //不符合正则匹配的提示语句
  344. // }).then(({ value }) => {
  345. // //parentId:data.id
  346. // organizationcaeatre({ displayName: value, parentId: data.id }).then(
  347. // (res) => {
  348. // this.getonorganization();
  349. // this.$message.success("新增成功");
  350. // }
  351. // );
  352. // });
  353. // }
  354. },
  355. //删除组织
  356. deleates(data) {
  357. this.$confirm("是否确定删除, 是否继续?", "提示", {
  358. confirmButtonText: "确定",
  359. cancelButtonText: "取消",
  360. type: "warning",
  361. }).then((res) => {
  362. deleteschema(data.data.id).then((res) => {
  363. if (res.code == 0) {
  364. console.log(res);
  365. this.$message.success("删除成功");
  366. this.getonorganization();
  367. }
  368. });
  369. console.log(data);
  370. });
  371. },
  372. //编辑组织
  373. rena(node, data) {
  374. let a = this.$refs.tree.getNode(data.id).parent.data.displayName;
  375. if (a == undefined) {
  376. this.departmentname = "已是最上级";
  377. console.log(this.departmentname);
  378. } else {
  379. this.departmentname = a;
  380. }
  381. // this.departmentname = a;
  382. console.log(a);
  383. console.log(this.departmentname);
  384. // this.departmentname = localStorage.getItem("departmentname");
  385. console.log(data, "data");
  386. this.dialogVisible = true;
  387. this.title = 2;
  388. console.log(this.form.isPeis);
  389. // this.selecttable.push(data);
  390. this.showcheckbox = true;
  391. this.form = data;
  392. this.form.isPeis = "N";
  393. // console.log(this.selecttable, 5555);
  394. getapi(
  395. `/api/app/organizationunit/getbycodeparent?OrganizationUnitId=${data.id}`
  396. ).then((res) => {
  397. this.selecttable = res.data;
  398. console.log(res, "res");
  399. });
  400. // getapi(`/api/app/organization-units?Id=${data.id}`).then((res) => {
  401. // this.form = res.data;
  402. // console.log(res);
  403. // });
  404. // this.form = data;
  405. // console.log(this.form);
  406. // console.log(data);
  407. // this.$prompt("组织名称", "修改组织", {
  408. // confirmButtonText: "确定",
  409. // cancelButtonText: "取消",
  410. // // inputPattern: /^[\u4e00-\u9fa5]{0,}$/, //匹配全中文
  411. // // inputErrorMessage: "请输入中文", //不符合正则匹配的提示语句
  412. // }).then(({ value }) => {
  413. // console.log(value);
  414. // modifyedit(data.id, value).then((res) => {
  415. // this.getonorganization();
  416. // // console.log(res)
  417. // this.$message.success("修改成功");
  418. // });
  419. // });
  420. },
  421. },
  422. };
  423. </script>
  424. <style scoped>
  425. .publicfontsize {
  426. font-size: 18px;
  427. }
  428. .el-icon-plus {
  429. margin-left: 10%;
  430. }
  431. .el-icon-delete {
  432. margin-left: 5%;
  433. }
  434. .el-icon-edit {
  435. margin-left: 5%;
  436. }
  437. .allC {
  438. display: flex;
  439. }
  440. </style>