setDept.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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" @ok="ok"
  35. @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 ids1 = this.zxzData.map((item) => item.id);
  122. let ids2 = this.zxzData.map((item) => {
  123. return {
  124. id: item.id,
  125. };
  126. });
  127. let postData1 = {
  128. quickId: this.id,
  129. deptIds: ids1.join(),
  130. userId: this.userId,
  131. changeDept: 1
  132. };
  133. let postData2 = {
  134. workConfigHistory: {
  135. user: {
  136. id: this.userId,
  137. },
  138. workAllocationQuick: {
  139. id: this.id,
  140. },
  141. deptList: ids2,
  142. hosId: uni.getStorageSync("userData").user.currentHospital.id
  143. },
  144. };
  145. uni.showLoading({
  146. title: "加载中",
  147. mask: true,
  148. });
  149. if (this.changedept == 1) { //单纯切换科室!!!!
  150. //切换负责科室,不重新上班
  151. post("/auth/customOnline", postData1).then((res) => {
  152. if (res.status == 200) {
  153. post("/configuration/addData/workConfigHistory", postData2).then(
  154. (result) => {
  155. uni.hideLoading();
  156. if (result.status == 200) {
  157. uni.redirectTo({
  158. url: "../receiptpage/receiptpage",
  159. });
  160. } else {
  161. uni.showToast({
  162. icon: "none",
  163. title: "请求失败!",
  164. });
  165. }
  166. }
  167. );
  168. } else if (res.status == 504) {
  169. uni.hideLoading();
  170. let dept = res.department.dept;
  171. let user = res.user.name;
  172. let phone = res.user.phone;
  173. this.models = {
  174. disjunctor: true,
  175. title: "提示",
  176. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  177. icon: "warn",
  178. phone,
  179. operate: {
  180. know: "知道了",
  181. },
  182. };
  183. } else if (res.status == 505) {
  184. uni.hideLoading();
  185. this.models1 = {
  186. disjunctor: true,
  187. title: "提示",
  188. content: res.msg, //baba
  189. icon: "warn",
  190. operate: {
  191. know: "知道了",
  192. },
  193. };
  194. }
  195. });
  196. } else {
  197. post("/auth/onOrOffLine", {
  198. type: "on",
  199. customWorking: "on",
  200. quickId: this.id,
  201. deptIds: ids1.join(),
  202. userId: this.userId,
  203. }).then((res) => {
  204. if (res.status == 200) {
  205. post("/configuration/addData/workConfigHistory", postData2).then(
  206. (result) => {
  207. uni.hideLoading();
  208. if (result.status == 200) {
  209. let obj = uni.getStorageSync("userData");
  210. obj.user.online = true;
  211. uni.setStorageSync("userData", obj);
  212. uni.redirectTo({
  213. url: "../receiptpage/receiptpage",
  214. });
  215. } else {
  216. uni.showToast({
  217. icon: "none",
  218. title: "请求失败!",
  219. });
  220. }
  221. }
  222. );
  223. } else if (res.status == 504) {
  224. uni.hideLoading();
  225. let dept = res.department.dept;
  226. let user = res.user.name;
  227. let phone = res.user.phone;
  228. this.models = {
  229. disjunctor: true,
  230. title: "提示",
  231. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  232. icon: "warn",
  233. phone,
  234. operate: {
  235. know: "知道了",
  236. },
  237. };
  238. }
  239. });
  240. }
  241. }
  242. },
  243. // 获取科室列表
  244. getDeptList() {
  245. uni.showLoading({
  246. title: "加载中",
  247. mask: true,
  248. });
  249. post("/auth/getUserWorkDept", {}).then((res) => {
  250. uni.hideLoading();
  251. if (res.status == 200) {
  252. this.zxzData = res.data;
  253. uni.setStorageSync("setDepts", this.zxzData); //存科室列表
  254. } else {
  255. uni.showToast({
  256. icon: "none",
  257. title: "请求失败!",
  258. });
  259. }
  260. });
  261. },
  262. },
  263. onLoad(options) {
  264. console.log(options);
  265. this.configName = options.configName;
  266. this.id = options.id;
  267. this.changedept = options.changedept;
  268. if (uni.getStorageSync("setDepts")) {
  269. this.zxzData = uni.getStorageSync("setDepts");
  270. } else {
  271. this.getDeptList();
  272. }
  273. },
  274. };
  275. </script>
  276. <style lang="less">
  277. .setDept {
  278. width: 100%;
  279. height: 100%;
  280. position: relative;
  281. .page_tab {
  282. width: 100%;
  283. height: 96rpx;
  284. display: flex;
  285. position: fixed;
  286. left: 0;
  287. top: 0;
  288. z-index: 999;
  289. .page_tab_bar {
  290. flex: 1;
  291. font-size: 36rpx;
  292. background: #fff;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. position: relative;
  297. &:after {
  298. content: "";
  299. position: absolute;
  300. left: 0;
  301. bottom: 0;
  302. height: 2rpx;
  303. width: 100%;
  304. background-color: transparent;
  305. }
  306. .tab_dept {
  307. position: relative;
  308. .addDept {
  309. white-space: nowrap;
  310. margin: 0;
  311. position: absolute;
  312. right: 0;
  313. top: 50%;
  314. transform: translate(105%, -50%);
  315. padding: 0 0.5em;
  316. line-height: 2;
  317. }
  318. }
  319. &.active {
  320. color: #49b856;
  321. &:after {
  322. background-color: #49b856;
  323. }
  324. }
  325. }
  326. }
  327. .zwsj {
  328. position: absolute;
  329. left: 50%;
  330. top: 180rpx;
  331. transform: translateX(-50%);
  332. .zwsj-img {
  333. width: 560rpx;
  334. }
  335. .zwsj-txt {
  336. font-size: 36rpx;
  337. font-weight: 700;
  338. margin-top: 20rpx;
  339. text-align: center;
  340. }
  341. }
  342. .page_items {
  343. height: calc(100vh - 184rpx);
  344. padding-top: 96rpx;
  345. overflow: auto;
  346. .page_items_scroll {
  347. height: 100%;
  348. .keyword-entry-tap {
  349. background-color: #eee;
  350. }
  351. .keyword-entry {
  352. width: 94%;
  353. height: 80upx;
  354. padding: 0 3%;
  355. font-size: 30upx;
  356. color: #333;
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. border-bottom: solid 1upx #e7e7e7;
  361. .keyword-text,
  362. .keyword-img {
  363. height: 80upx;
  364. display: flex;
  365. align-items: center;
  366. }
  367. .keyword-text {
  368. width: 90%;
  369. }
  370. .keyword-img {
  371. width: 20%;
  372. justify-content: center;
  373. color: #49b856;
  374. }
  375. }
  376. }
  377. }
  378. // 底部
  379. .toolbar {
  380. position: fixed;
  381. left: 0;
  382. right: 0;
  383. bottom: 0;
  384. z-index: 9999;
  385. height: 88rpx;
  386. display: flex;
  387. justify-content: center;
  388. align-items: center;
  389. box-sizing: border-box;
  390. border-radius: 4rpx;
  391. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.24);
  392. background-color: #e5e9ed;
  393. .toolbar-sao {
  394. font-size: 36rpx;
  395. color: #49b856;
  396. }
  397. }
  398. }
  399. </style>