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.

435 lines
14 KiB

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