showModel.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="showModel" v-show="disjunctor">
  3. <view class="showModel__wrap">
  4. <view class="showModel__header" v-if="title">
  5. {{ title }}
  6. <text v-if="operate.know == '知道了' && timerFlag">({{ time }})</text>
  7. </view>
  8. <view class="showModel__article" :class="{ p0: textareaFlag, p1: radioInspectionDistanceItem.length, p2: childrenDeptList.length || busyContentList.length }">
  9. <text
  10. v-if="icon"
  11. class="showModel__icon newicon"
  12. :class="[
  13. 'showModel__icon--' + icon,
  14. { 'newicon-duigou': icon === 'success' },
  15. { 'newicon-shibai': icon === 'error' },
  16. { 'newicon-wenhao': icon === 'warn' },
  17. ]"
  18. ></text>
  19. <view v-if="content" class="showModel__content" @click="tel()" v-html="content"></view>
  20. <view v-if="info" class="showModel__info">{{ info }}</view>
  21. <view class="specialCloseFlag" v-if="textareaFlag">
  22. <textarea
  23. style="width: 100%"
  24. placeholder="请输入5~100个文字方可提交!"
  25. maxlength="100"
  26. @input="textareaInput"
  27. />
  28. </view>
  29. <view class="radio-wrap" v-if="radioItem.length">
  30. <radio-group @change="radioChange">
  31. <view v-for="(item, index) in radioItem" :key="item.qrcode" class="radio-item">
  32. <label>
  33. <radio :value="item.qrcode" :checked="index === 0" />
  34. <text>{{ item.deptName }}</text>
  35. </label>
  36. </view>
  37. </radio-group>
  38. </view>
  39. <view class="radio-wrap" v-if="radioInspectionDistanceItem.length">
  40. <radio-group @change="radioChange">
  41. <view v-for="(item, index) in radioInspectionDistanceItem" :key="item.id" class="radio-item">
  42. <label>
  43. <radio :value="item.id" />
  44. <text>{{ item.inspectMode }}</text>
  45. </label>
  46. </view>
  47. </radio-group>
  48. </view>
  49. <view class="childrenDeptList" v-if="childrenDeptList.length">
  50. <view @click="clickHandler(item)" v-for="(item, index) in childrenDeptList" :key="item.id" class="childrenDeptItem">{{ item.dept }}</view>
  51. </view>
  52. <view class="busyContentList" v-if="busyContentList.length">
  53. <view @click="clickHandler(item)" v-for="(item, index) in busyContentList" :key="index" class="childrenDeptItem">{{ item.busyContent }}</view>
  54. </view>
  55. </view>
  56. <view class="showModel__footer">
  57. <view
  58. v-if="operate.ok"
  59. class="showModel__ok"
  60. @click="ok"
  61. hover-class="seimin-btn-hover"
  62. >{{ operate.ok || "" }}</view
  63. >
  64. <view
  65. v-if="operate.no"
  66. class="showModel__ok"
  67. @click="no"
  68. hover-class="seimin-btn-hover"
  69. >{{ operate.no || "" }}</view
  70. >
  71. <view
  72. v-if="operate.cancel"
  73. class="showModel__cancel"
  74. @click="cancel"
  75. hover-class="seimin-btn-hover"
  76. >{{ operate.cancel || "" }}</view
  77. >
  78. <view
  79. v-if="operate.know"
  80. class="showModel__know"
  81. @click="know"
  82. hover-class="seimin-btn-hover"
  83. >{{ operate.know || "" }}</view
  84. >
  85. <view
  86. v-if="operate.know && timerFlag"
  87. class="showModel__know"
  88. @click="cancelTimer"
  89. hover-class="seimin-btn-hover"
  90. >取消自动关闭</view
  91. >
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. export default {
  98. data() {
  99. return {
  100. time: 5, //5秒后自动关闭
  101. timer: null, //5秒后自动关闭,定时器
  102. timerFlag: true, //是否显示取消自动关闭按钮
  103. };
  104. },
  105. watch: {
  106. disjunctor(newValue) {
  107. if (newValue && this.operate.know == "知道了") {
  108. this.time = 5;
  109. this.timerFlag = true;
  110. this.timer = setInterval(() => {
  111. this.time--;
  112. if (this.time <= 0) {
  113. clearInterval(this.timer);
  114. this.know();
  115. }
  116. }, 1000);
  117. }
  118. },
  119. },
  120. props: {
  121. // 显示隐藏
  122. disjunctor: {
  123. type: Boolean,
  124. default: false,
  125. },
  126. // 标题
  127. title: {
  128. type: String,
  129. default: "提示",
  130. },
  131. // 图标
  132. icon: {
  133. type: String,
  134. default: "success",
  135. },
  136. // 内容
  137. content: {
  138. type: String,
  139. default: "",
  140. },
  141. // 说明
  142. info: {
  143. type: String,
  144. default: "",
  145. },
  146. // 拨打电话
  147. phone: {
  148. type: String,
  149. default: "",
  150. },
  151. // 特殊情况关闭原因
  152. textareaFlag: {
  153. type: Boolean,
  154. default: false,
  155. },
  156. // 单选框选项
  157. radioItem: {
  158. type: Array,
  159. default: () => {
  160. return [];
  161. },
  162. },
  163. // 单选框选项-陪检方式
  164. radioInspectionDistanceItem: {
  165. type: Array,
  166. default: () => {
  167. return [];
  168. },
  169. },
  170. // 子科室列表
  171. childrenDeptList: {
  172. type: Array,
  173. default: () => {
  174. return [];
  175. },
  176. },
  177. // 示忙原因
  178. busyContentList: {
  179. type: Array,
  180. default: () => {
  181. return [];
  182. },
  183. },
  184. // 操作按钮文字
  185. operate: {
  186. type: Object,
  187. default: () => {
  188. return {
  189. know: "知道了",
  190. };
  191. },
  192. },
  193. },
  194. methods: {
  195. clickHandler(item){
  196. this.$emit('ok', item)
  197. },
  198. // 单选框选中
  199. radioChange(item){
  200. this.$emit('radioChange',item.target.value)
  201. },
  202. // 输入文字
  203. textareaInput(e) {
  204. this.$emit("textareaInput", e.detail.value);
  205. },
  206. // 确定
  207. ok() {
  208. this.$emit("ok");
  209. },
  210. // 否
  211. no() {
  212. this.$emit("no");
  213. },
  214. // 取消
  215. cancel() {
  216. this.$emit("cancel");
  217. },
  218. // 知道了
  219. know() {
  220. clearInterval(this.timer);
  221. this.$emit("know");
  222. },
  223. // 取消自动关闭
  224. cancelTimer() {
  225. this.timerFlag = false;
  226. clearInterval(this.timer);
  227. },
  228. // 拨打电话
  229. tel() {
  230. if (this.phone) {
  231. uni.makePhoneCall({
  232. phoneNumber: this.phone,
  233. });
  234. }
  235. },
  236. },
  237. };
  238. </script>
  239. <style lang="less" scoped>
  240. .showModel {
  241. position: fixed;
  242. left: 0;
  243. right: 0;
  244. top: 0;
  245. bottom: 0;
  246. background-color: rgba(0, 0, 0, 0.2);
  247. z-index: 999999;
  248. .showModel__wrap {
  249. width: 560rpx;
  250. position: absolute;
  251. left: 50%;
  252. top: 50%;
  253. transform: translate(-50%, -50%);
  254. background-color: #fff;
  255. border-radius: 12rpx;
  256. .showModel__header {
  257. font-size: 36rpx;
  258. color: #000;
  259. height: 84rpx;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. }
  264. .showModel__article {
  265. color: #000;
  266. margin: 0 auto 25rpx;
  267. width: 488rpx;
  268. padding: 60rpx 16rpx;
  269. background-color: rgb(249, 250, 251);
  270. border: 2rpx solid rgb(229, 233, 237);
  271. border-radius: 12rpx;
  272. box-sizing: border-box;
  273. display: flex;
  274. flex-direction: column;
  275. justify-content: center;
  276. align-items: center;
  277. text-align: justify;
  278. &.p0 {
  279. padding: 0;
  280. }
  281. &.p1 {
  282. text-align: left;
  283. }
  284. &.p2 {
  285. text-align: center;
  286. }
  287. .childrenDeptList, .busyContentList{
  288. width: 100%;
  289. max-height: 50vh;
  290. overflow-y: auto;
  291. .childrenDeptItem{
  292. background-color: #fff;
  293. height: 80rpx;
  294. line-height: 80rpx;
  295. border-radius: 80rpx;
  296. color: #49b856;
  297. margin-top: 24rpx;
  298. white-space: nowrap;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. }
  302. }
  303. .showModel__icon {
  304. font-size: 138rpx;
  305. margin-bottom: 32rpx;
  306. &.showModel__icon--success {
  307. color: rgb(52, 179, 73);
  308. }
  309. &.showModel__icon--warn {
  310. color: rgb(245, 165, 35);
  311. }
  312. &.showModel__icon--error {
  313. color: rgb(255, 58, 82);
  314. }
  315. }
  316. .showModel__content {
  317. font-size: 36rpx;
  318. word-break: break-all;
  319. }
  320. .showModel__info {
  321. font-size: 32rpx;
  322. color: rgb(102, 102, 102);
  323. }
  324. .specialCloseFlag {
  325. width: 90%;
  326. height: 100%;
  327. padding: 16rpx;
  328. }
  329. .radio-wrap{
  330. .radio-item{
  331. margin-top: 16rpx;
  332. /deep/ .uni-radio-input-checked{
  333. background-color: #49b856!important;
  334. border-color: #49b856!important;
  335. }
  336. }
  337. }
  338. }
  339. .showModel__footer {
  340. box-sizing: border-box;
  341. height: 100rpx;
  342. border-top: 2rpx solid rgb(229, 233, 237);
  343. display: flex;
  344. align-items: center;
  345. view {
  346. height: 100%;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. font-size: 36rpx;
  351. color: rgb(102, 102, 102);
  352. position: relative;
  353. & ~ view::before {
  354. content: "";
  355. position: absolute;
  356. left: 0;
  357. bottom: 0;
  358. width: 2rpx;
  359. height: 87rpx;
  360. background-color: rgb(229, 233, 237);
  361. }
  362. }
  363. .showModel__ok {
  364. flex: 1;
  365. color: rgb(73, 184, 86);
  366. }
  367. .showModel__cancel {
  368. flex: 1;
  369. }
  370. .showModel__know {
  371. flex: 1;
  372. color: rgb(73, 184, 86);
  373. }
  374. }
  375. }
  376. }
  377. </style>