seiminModel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <!--
  2. * @Author: 廖明明
  3. * @Date: 2022-04-01 17:11:19
  4. * @LastEditors: 廖明明
  5. * @LastEditTime: 2022-04-21 13:16:48
  6. * @Description: 自定义弹窗组件
  7. -->
  8. <template>
  9. <view class="seiminModel seiminModel_mask" v-if="opts.isVisible">
  10. <view class="seiminModel_container animate__animated animate__fadeIn animate__faster">
  11. <!-- 标题 -->
  12. <view class="seiminModel_header" :class="{noTitle:!opts.title}">
  13. <text>{{ opts.title }}</text>
  14. <text class="seiminModel_countDown" v-if="
  15. nurseDeptSwitchTip < 0 || (nurseDeptSwitchTip > 0 && closeTime > 0)
  16. ">
  17. <text v-if="nurseDeptSwitchTip < 0">关闭</text>倒计时<text>{{ closeTime }}s</text>
  18. </text>
  19. </view>
  20. <!-- 动态二维码 -->
  21. <view class="seiminModel_content qrcode" v-if="opts.skin === 'qrcode'">
  22. <image class="w100" :src="nurseCodeImg" mode="widthFix"></image>
  23. <view class="qrcode_operate">
  24. <view class="refreshQRCode" @click="showNurseCode"> 刷新 </view>
  25. <view>{{ refreshQRCodeTime }}s</view>
  26. </view>
  27. </view>
  28. <!-- 加急 -->
  29. <view class="seiminModel_content urgent" v-else-if="opts.skin === 'urgent'">
  30. <view class="urgent_txt" v-html="opts.content"></view>
  31. <textarea :focus="true" class="urgent_textarea" auto-height :maxlength="100"
  32. :placeholder-style="placeholderStyle" placeholder="请填写加急原因" v-model="urgentTextArea" />
  33. </view>
  34. <!-- 评价 -->
  35. <view class="seiminModel_content evaluate" v-else-if="opts.skin === 'evaluate'">
  36. <view class="evaluate_txt" v-html="opts.content"></view>
  37. <view class="evaluate_list">
  38. <view class="evaluate_item">
  39. <text class="evaluate_label">星级:</text>
  40. <view class="evaluate_icons">
  41. <text class="pda" :class="star" v-for="(star,i) in stars" :key="i"></text>
  42. </view>
  43. </view>
  44. <view class="evaluate_item">
  45. <text class="evaluate_label">评级:</text>
  46. <textarea :focus="true" class="evaluate_textarea" auto-height :maxlength="100"
  47. :placeholder-style="placeholderStyle" placeholder="请输入..." v-model="urgentTextArea" />
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 正常弹窗 -->
  52. <view class="seiminModel_content" v-else>
  53. <!-- 图标 -->
  54. <view class="seiminModel_status">
  55. <text class="pda pda-shibai red" v-if="opts.icon === 'error'"></text>
  56. <text class="pda pda-wenhao yellow" v-if="opts.icon === 'warn'"></text>
  57. <text class="pda pda-duigou green" v-if="opts.icon === 'success'"></text>
  58. </view>
  59. <!-- 内容 -->
  60. <view class="seiminModel_txt" v-html="opts.content"></view>
  61. </view>
  62. <!-- 底部 -->
  63. <view class="seiminModel_footer" v-if="
  64. nurseDeptSwitchTip <= 0 || (nurseDeptSwitchTip > 0 && closeTime === 0)
  65. ">
  66. <view class="seiminModel_footer__btn" v-for="(btn, i) in opts.btns" :style="{
  67. flex: btn.flex,
  68. color: btn.textColor,
  69. }" @click="btn.click($event)" :key="i">{{ btn.name }}</view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. mapState
  77. } from "vuex";
  78. import {
  79. reqDeptCodes
  80. } from "../../request/api.js";
  81. export default {
  82. name: "seiminModel",
  83. data() {
  84. return {
  85. // 配置项
  86. opts: {},
  87. // 动态二维码定时器
  88. timer: null,
  89. // 动态二维码qrcode
  90. nurseCodeImg: "",
  91. // 动态二维码刷新间隔时长
  92. refreshQRCodeTime: 30,
  93. // 护士科室切换提示自动关闭设置(时长,单位秒)
  94. closeTime: 0,
  95. // 护士科室切换提示自动关闭设置(定时器,单位秒)
  96. timerCloseTime: null,
  97. // 加急原因
  98. urgentTextArea: '',
  99. // 加急原因的placeholder样式
  100. placeholderStyle: 'color:#999;padding:18rpx;',
  101. // 星级
  102. stars: [],
  103. };
  104. },
  105. computed: {
  106. ...mapState('other', ["nurseDeptSwitchTip"]),
  107. ...mapState("login", ["loginInfo"]),
  108. },
  109. methods: {
  110. // 显示弹窗
  111. show(args = {}) {
  112. this.stars = ['pda-haoping','pda-haoping','pda-haoping','pda-haoping','pda-haoping']
  113. // 默认配置项
  114. let defaultOptions = {
  115. skin: "default", //弹窗风格(default|toast|qrcode|)
  116. isVisible: false, //是否显示弹窗
  117. title: "提示", //标题
  118. icon: "success", //图标(success|error|warn|)
  119. content: "", //内容
  120. btns: [{
  121. name: "取消",
  122. textColor: "#666",
  123. flex: 1,
  124. click: this.close,
  125. },
  126. {
  127. name: "确认",
  128. textColor: "#49B856",
  129. flex: 1,
  130. click: this.close,
  131. },
  132. ], //弹窗按钮
  133. };
  134. // 根据弹窗风格修改默认配置项
  135. switch (args.skin) {
  136. case "toast":
  137. defaultOptions.btns = [{
  138. name: "知道了",
  139. textColor: "#49b856",
  140. flex: 1,
  141. click: this.close,
  142. }, ];
  143. break;
  144. }
  145. // 按钮合并参数
  146. if (Array.isArray(args.btns)) {
  147. let btns = [];
  148. args.btns.forEach((v, i) => {
  149. btns.push(Object.assign({}, defaultOptions.btns[i], v));
  150. });
  151. args.btns = btns;
  152. }
  153. // 合并配置
  154. this.opts = Object.assign({}, defaultOptions, args, {
  155. isVisible: true,
  156. });
  157. // 如果是动态二维码,则需要发起请求
  158. if (this.opts.skin === "qrcode") {
  159. this.showNurseCode();
  160. }
  161. },
  162. // 关闭弹窗
  163. close() {
  164. this.opts.isVisible = false;
  165. if (this.opts.skin === "qrcode") {
  166. clearInterval(this.timer);
  167. this.timer = null;
  168. }
  169. },
  170. // 科室动态二维码方法
  171. showNurseCode() {
  172. let deptId = this.loginInfo.user && this.loginInfo.user.dept.id;
  173. reqDeptCodes([deptId]).then((res) => {
  174. if (res.status == 200) {
  175. res["data"] = res["data"] || [];
  176. res["data"][0] = res["data"][0] || {};
  177. this.nurseCodeImg = res["data"][0].base64 || "";
  178. this.refreshQRCodeTime = res["data"][0].refreshQRCodeTime || 30;
  179. clearInterval(this.timer);
  180. this.timer = setInterval(() => {
  181. this.refreshQRCodeTime = Math.max(--this.refreshQRCodeTime, 0);
  182. if (this.refreshQRCodeTime === 0) {
  183. clearInterval(this.timer);
  184. this.showNurseCode();
  185. }
  186. }, 1000);
  187. } else {
  188. clearInterval(this.timer);
  189. uni.showToast({
  190. icon: "none",
  191. title: "获取数据失败",
  192. });
  193. }
  194. });
  195. },
  196. // 切换科室弹窗
  197. showChangeDept(options = {}) {
  198. this.show(options);
  199. // (1) 当用户设置为正数时,用户必须查看此窗体指定秒数。
  200. // (2) 当用户设置为负数时,用户可点击知道了也可倒计时自动关闭。
  201. // (3) 如果用户填写0则为无自动关闭和强制查看时间。
  202. if (this.nurseDeptSwitchTip === 0) {
  203. return;
  204. }
  205. this.closeTime = Math.abs(this.nurseDeptSwitchTip);
  206. clearInterval(this.timerCloseTime);
  207. this.timerCloseTime = setInterval(() => {
  208. this.closeTime = Math.max(--this.closeTime, 0);
  209. if (this.closeTime === 0) {
  210. if (this.nurseDeptSwitchTip < 0) {
  211. this.close();
  212. }
  213. clearInterval(this.timerCloseTime);
  214. }
  215. }, 1000);
  216. },
  217. },
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .seiminModel {
  222. font-size: 36rpx;
  223. color: #000;
  224. line-height: 50rpx;
  225. text-align: center;
  226. &.seiminModel_mask {
  227. background-color: rgba(0, 0, 0, 0.5);
  228. position: fixed;
  229. top: 0;
  230. right: 0;
  231. bottom: 0;
  232. left: 0;
  233. margin: auto;
  234. z-index: 9999;
  235. @include flex(center, center);
  236. .seiminModel_container {
  237. width: 560rpx;
  238. border-radius: 8rpx;
  239. background-color: #fff;
  240. display: flex;
  241. flex-direction: column;
  242. align-content: center;
  243. .seiminModel_status {
  244. margin-bottom: 35rpx;
  245. .pda {
  246. font-size: 138rpx;
  247. }
  248. }
  249. .seiminModel_header {
  250. height: 100rpx;
  251. position: relative;
  252. @include flex(center, center);
  253. &.noTitle {
  254. height: 40rpx;
  255. }
  256. .seiminModel_countDown {
  257. position: absolute;
  258. right: 26rpx;
  259. font-size: 28rpx;
  260. color: $defaultColor;
  261. }
  262. }
  263. .seiminModel_content {
  264. flex: 1;
  265. background-color: #f9fafb;
  266. margin: 0 36rpx 25rpx;
  267. border: 1px solid #e5e9ed;
  268. color: #333;
  269. padding: 76rpx 24rpx;
  270. @include numbersAndLettersNoWrap;
  271. // 动态二维码
  272. &.qrcode {
  273. padding: 24rpx;
  274. font-size: 32rpx;
  275. color: #999;
  276. .qrcode_operate {
  277. @include flex(space-between, center);
  278. .refreshQRCode {
  279. color: $defaultColor;
  280. }
  281. }
  282. }
  283. // 加急
  284. &.urgent {
  285. padding: 0;
  286. .urgent_txt {
  287. font-size: 28rpx;
  288. color: #666;
  289. line-height: 40rpx;
  290. border-bottom: 2rpx solid #E5E9ED;
  291. padding: 24rpx;
  292. }
  293. .urgent_textarea {
  294. width: 440rpx;
  295. margin: 24rpx;
  296. min-height: 212rpx;
  297. background: #FFFFFF;
  298. border-radius: 2rpx;
  299. border: 2rpx solid #E5E9ED;
  300. text-align: left;
  301. ::v-deep .uni-textarea-textarea {
  302. padding: 18rpx;
  303. }
  304. }
  305. }
  306. // 评价
  307. &.evaluate {
  308. padding: 0;
  309. .evaluate_txt {
  310. font-size: 28rpx;
  311. color: #666;
  312. line-height: 40rpx;
  313. border-bottom: 2rpx solid #E5E9ED;
  314. padding: 24rpx 0;
  315. }
  316. .evaluate_list {
  317. padding: 20rpx 34rpx;
  318. .evaluate_item {
  319. font-size: 34rpx;
  320. color: #666;
  321. margin-top: 10rpx;
  322. @include flex;
  323. .evaluate_label {}
  324. .evaluate_icons {
  325. flex: 1;
  326. @include flex;
  327. .pda {
  328. font-size: 40rpx;
  329. margin-right: 10rpx;
  330. &.pda-haoping {
  331. color: $defaultColor;
  332. }
  333. }
  334. }
  335. .evaluate_textarea {
  336. flex: 1;
  337. min-height: 212rpx;
  338. background: #FFFFFF;
  339. border-radius: 2rpx;
  340. border: 2rpx solid #E5E9ED;
  341. text-align: left;
  342. ::v-deep .uni-textarea-textarea {
  343. padding: 18rpx;
  344. }
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .seiminModel_footer {
  351. border-top: 1px solid #e5e5e5;
  352. height: 100rpx;
  353. color: #666;
  354. @include flex(center, center);
  355. .seiminModel_footer__btn {
  356. height: 100%;
  357. @include flex(center, center);
  358. position: relative;
  359. &::after {
  360. content: "";
  361. height: 86rpx;
  362. position: absolute;
  363. width: 1px;
  364. bottom: 0;
  365. right: 0;
  366. background-color: #dde1e5;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. </style>