setDept.vue 12 KB

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