setDept.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="setDept">
  3. <view class="page_tab">
  4. <view class="page_tab_bar active">
  5. <view class="tab_dept">{{ configName
  6. }}<button type="default" size="mini" class="addDept" @click="addDeptClick">
  7. 添加科室
  8. </button></view>
  9. </view>
  10. </view>
  11. <view v-if="zxzData.length == 0" class="zwsj">
  12. <image class="zwsj-img" mode="widthFix" src="../../static/img/zanwushuju.png"></image>
  13. <view class="zwsj-txt">暂无数据</view>
  14. </view>
  15. <view v-if="zxzData.length" class="page_items">
  16. <view class="page_items_scroll">
  17. <block v-for="row in zxzData" :key="row.id">
  18. <view class="keyword-entry" hover-class="keyword-entry-tap">
  19. <view class="keyword-text">
  20. <rich-text :nodes="row.dept"></rich-text>
  21. </view>
  22. <view class="keyword-img" @tap.stop="deleteDept(row.id)">
  23. 删除科室
  24. </view>
  25. </view>
  26. </block>
  27. </view>
  28. </view>
  29. <!-- 底部确认负责科室 -->
  30. <view class="toolbar" @click="determine()" hover-class="seimin-btn-hover">
  31. <text class="toolbar-sao">确认负责科室</text>
  32. </view>
  33. <!-- 弹窗 -->
  34. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
  35. @ok="ok" @cancel="cancel" @know="know" :operate="models.operate" :phone="models.phone"></showModel>
  36. <!-- 提示下班弹窗 -->
  37. <showModel :title="models1.title" :icon="models1.icon" :disjunctor="models1.disjunctor" :content="models1.content"
  38. @know="know1" :operate="models1.operate"></showModel>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. post,
  44. get
  45. } from "../../http/http.js";
  46. export default {
  47. data() {
  48. return {
  49. configName: "", //快捷组合名称
  50. id: "", //快速组合的id
  51. changedept: 0, //是否是从切换负责科室过来的
  52. zxzData: [], //已选择的科室
  53. // 弹窗model
  54. models: {
  55. disjunctor: false,
  56. },
  57. // 下班弹窗model
  58. models1: {
  59. disjunctor: false,
  60. },
  61. delId: "", //科室删除的id
  62. userId: uni.getStorageSync("userData").user.id, //当前用户的id
  63. };
  64. },
  65. methods: {
  66. //知道了(下班弹窗)
  67. know1() {
  68. this.models1.disjunctor = false;
  69. uni.redirectTo({
  70. url: "../homePage/homePage",
  71. });
  72. },
  73. //知道了
  74. know() {
  75. this.models.disjunctor = false;
  76. },
  77. //确定
  78. ok() {
  79. this.models.disjunctor = false;
  80. let i = this.zxzData.findIndex((item) => item.id == this.delId);
  81. this.zxzData.splice(i, 1);
  82. uni.setStorageSync("setDepts", this.zxzData);
  83. },
  84. //取消
  85. cancel() {
  86. this.models.disjunctor = false;
  87. },
  88. // 添加科室
  89. addDeptClick() {
  90. uni.navigateTo({
  91. url: `../search/search?type=setDept&configName=${this.configName}&id=${this.id}&changedept=${this.changedept}`,
  92. });
  93. },
  94. // 删除科室
  95. deleteDept(id) {
  96. this.delId = id;
  97. this.models = {
  98. disjunctor: true,
  99. title: "提示",
  100. content: "您确定要删除该科室吗?",
  101. icon: "warn",
  102. operate: {
  103. ok: "确定",
  104. cancel: "取消",
  105. },
  106. };
  107. },
  108. // 确认负责科室
  109. determine() {
  110. if (this.zxzData.length === 0) {
  111. this.models = {
  112. disjunctor: true,
  113. title: "提示",
  114. content: "请选择至少一个科室",
  115. icon: "warn",
  116. operate: {
  117. know: "知道了",
  118. },
  119. };
  120. } else {
  121. let setDeptConfg = uni.getStorageSync("setDeptConfg");
  122. let ids1 = this.zxzData.map((item) => item.id);
  123. let ids2 = this.zxzData.map((item) => {
  124. return {
  125. id: item.id,
  126. };
  127. });
  128. let postData1 = {
  129. quickId: this.id,
  130. deptIds: ids1.join(),
  131. userId: this.userId,
  132. changeDept: 1,
  133. classId: setDeptConfg.classesId,
  134. };
  135. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 4 && this.changedept == 1) {
  136. //自选排班,科室绑定分组
  137. console.log(setDeptConfg)
  138. postData1.groupIds = setDeptConfg.selectGroupId.toString();
  139. postData1.isManager = true;
  140. }
  141. let postData2 = {
  142. workConfigHistory: {
  143. user: {
  144. id: this.userId,
  145. },
  146. workAllocationQuick: {
  147. id: this.id,
  148. },
  149. deptList: ids2,
  150. hosId: uni.getStorageSync("userData").user.currentHospital.id,
  151. classId: setDeptConfg.classesId,
  152. },
  153. };
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. });
  158. if (this.changedept == 1) {
  159. //单纯切换科室!!!!
  160. //切换负责科室,不重新上班
  161. post("/auth/customOnline", postData1).then((res) => {
  162. if (res.status == 200) {
  163. post("/configuration/addData/workConfigHistory", postData2).then(
  164. (result) => {
  165. uni.hideLoading();
  166. if (result.status == 200) {
  167. uni.redirectTo({
  168. url: "../receiptpage/receiptpage",
  169. });
  170. } else {
  171. uni.showToast({
  172. icon: "none",
  173. title: "请求失败!",
  174. });
  175. }
  176. }
  177. );
  178. } else if (res.status == 504) {
  179. uni.hideLoading();
  180. let dept = res.department.dept;
  181. let user = res.user.name;
  182. let phone = res.user.phone;
  183. this.models = {
  184. disjunctor: true,
  185. title: "提示",
  186. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  187. icon: "warn",
  188. phone,
  189. operate: {
  190. know: "知道了",
  191. },
  192. };
  193. } else if (res.status == 505) {
  194. uni.hideLoading();
  195. this.models1 = {
  196. disjunctor: true,
  197. title: "提示",
  198. content: res.msg, //baba
  199. icon: "warn",
  200. operate: {
  201. know: "知道了",
  202. },
  203. };
  204. }
  205. });
  206. } else {
  207. let postData = {
  208. type: "on",
  209. customWorking: "on",
  210. quickId: this.id,
  211. deptIds: ids1.join(),
  212. userId: this.userId,
  213. classId: setDeptConfg.classesId,
  214. };
  215. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 4) {
  216. //自选排班,科室绑定分组
  217. console.log(setDeptConfg)
  218. postData.groupIds = setDeptConfg.selectGroupId.toString();
  219. postData.isManager = true;
  220. }
  221. post("/auth/onOrOffLine", postData).then((res) => {
  222. if (res.status == 200) {
  223. post("/configuration/addData/workConfigHistory", postData2).then(
  224. (result) => {
  225. uni.hideLoading();
  226. if (result.status == 200) {
  227. let obj = uni.getStorageSync("userData");
  228. obj.user.online = true;
  229. uni.setStorageSync("userData", obj);
  230. uni.redirectTo({
  231. url: "../receiptpage/receiptpage",
  232. });
  233. } else {
  234. uni.showToast({
  235. icon: "none",
  236. title: "请求失败!",
  237. });
  238. }
  239. }
  240. );
  241. } else if (res.status == 504) {
  242. uni.hideLoading();
  243. let dept = res.department.dept;
  244. let user = res.user.name;
  245. let phone = res.user.phone;
  246. this.models = {
  247. disjunctor: true,
  248. title: "提示",
  249. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  250. icon: "warn",
  251. phone,
  252. operate: {
  253. know: "知道了",
  254. },
  255. };
  256. }
  257. });
  258. }
  259. }
  260. },
  261. // 获取科室列表
  262. getDeptList() {
  263. uni.showLoading({
  264. title: "加载中",
  265. mask: true,
  266. });
  267. let setDeptConfg = uni.getStorageSync("setDeptConfg");
  268. let postData = {};
  269. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 4 && this.changedept != 1) {
  270. //自选排班,科室绑定分组,切换科室的时候
  271. console.log(setDeptConfg)
  272. postData.quickId = this.id;
  273. postData.groupId = setDeptConfg.selectGroupId.toString();
  274. }
  275. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 3 && this.changedept != 1) {
  276. //自选排班,科室绑定人员,切换科室的时候
  277. postData.quickId = this.id;
  278. }
  279. post("/auth/getUserWorkDept", postData).then((res) => {
  280. uni.hideLoading();
  281. if (res.status == 200) {
  282. this.zxzData = res.data;
  283. if (res.settings) {
  284. if (res.settings.groupManager) {
  285. setDeptConfg.selectGroupId = res.settings.groupManager.groupIds;
  286. uni.setStorageSync('setDeptConfg', setDeptConfg);
  287. }
  288. }
  289. uni.setStorageSync("setDepts", this.zxzData); //存科室列表
  290. }
  291. });
  292. },
  293. },
  294. onLoad(options) {
  295. console.log(options);
  296. this.configName = options.configName;
  297. this.id = options.id;
  298. this.changedept = options.changedept;
  299. if (uni.getStorageSync("setDepts")) {
  300. this.zxzData = uni.getStorageSync("setDepts");
  301. } else {
  302. this.getDeptList();
  303. }
  304. },
  305. };
  306. </script>
  307. <style lang="less">
  308. .setDept {
  309. width: 100%;
  310. height: 100%;
  311. position: relative;
  312. .page_tab {
  313. width: 100%;
  314. height: 96rpx;
  315. display: flex;
  316. position: fixed;
  317. left: 0;
  318. top: 0;
  319. z-index: 999;
  320. .page_tab_bar {
  321. flex: 1;
  322. font-size: 36rpx;
  323. background: #fff;
  324. display: flex;
  325. justify-content: center;
  326. align-items: center;
  327. position: relative;
  328. &:after {
  329. content: "";
  330. position: absolute;
  331. left: 0;
  332. bottom: 0;
  333. height: 2rpx;
  334. width: 100%;
  335. background-color: transparent;
  336. }
  337. .tab_dept {
  338. position: relative;
  339. .addDept {
  340. white-space: nowrap;
  341. margin: 0;
  342. position: absolute;
  343. right: 0;
  344. top: 50%;
  345. transform: translate(105%, -50%);
  346. padding: 0 0.5em;
  347. line-height: 2;
  348. }
  349. }
  350. &.active {
  351. color: #49b856;
  352. &:after {
  353. background-color: #49b856;
  354. }
  355. }
  356. }
  357. }
  358. .zwsj {
  359. position: absolute;
  360. left: 50%;
  361. top: 180rpx;
  362. transform: translateX(-50%);
  363. .zwsj-img {
  364. width: 560rpx;
  365. }
  366. .zwsj-txt {
  367. font-size: 36rpx;
  368. font-weight: 700;
  369. margin-top: 20rpx;
  370. text-align: center;
  371. }
  372. }
  373. .page_items {
  374. height: calc(100vh - 184rpx);
  375. padding-top: 96rpx;
  376. overflow: auto;
  377. .page_items_scroll {
  378. height: 100%;
  379. .keyword-entry-tap {
  380. background-color: #eee;
  381. }
  382. .keyword-entry {
  383. width: 94%;
  384. height: 80upx;
  385. padding: 0 3%;
  386. font-size: 30upx;
  387. color: #333;
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. border-bottom: solid 1upx #e7e7e7;
  392. .keyword-text,
  393. .keyword-img {
  394. height: 80upx;
  395. display: flex;
  396. align-items: center;
  397. }
  398. .keyword-text {
  399. width: 90%;
  400. }
  401. .keyword-img {
  402. width: 20%;
  403. justify-content: center;
  404. color: #49b856;
  405. }
  406. }
  407. }
  408. }
  409. // 底部
  410. .toolbar {
  411. position: fixed;
  412. left: 0;
  413. right: 0;
  414. bottom: 0;
  415. z-index: 9999;
  416. height: 88rpx;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. box-sizing: border-box;
  421. border-radius: 4rpx;
  422. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.24);
  423. background-color: #e5e9ed;
  424. .toolbar-sao {
  425. font-size: 36rpx;
  426. color: #49b856;
  427. }
  428. }
  429. }
  430. </style>