settingCode.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="settingCode">
  3. <view class="scanning_btn" hover-class="seimin-btn-hover" @click="drugsScanning()">
  4. <text class="icon_transport transport-saoma"></text>
  5. </view>
  6. <view class="scanFont">可通过扫一扫功能设置科室,扫描二维码后设置或替换科室</view>
  7. <view class="scanFont nr">
  8. <text>查询科室结果:{{queryDept?queryDept.dept:"无"}}</text>
  9. </view>
  10. <view class="scanFont nr red">{{msg}}</view>
  11. <footTool :settings="settings" @operate="operate"></footTool>
  12. <!-- 弹窗 -->
  13. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
  14. @ok="ok" @cancel="cancel" @know="know" :operate="models.operate"></showModel>
  15. </view>
  16. </template>
  17. <script>
  18. import footTool from "../../components/footTool/footTool.vue";
  19. import {
  20. get,
  21. post,
  22. SM,
  23. webHandle
  24. } from "../../http/http.js";
  25. export default {
  26. data() {
  27. return {
  28. queryDept: null, //根据二维码查询到的科室
  29. settings: [], //底部按钮设置
  30. msg: '', //提示信息
  31. // 弹窗model
  32. models: {
  33. disjunctor: false,
  34. },
  35. options: null, //url传参
  36. index: -1, //当前操作的索引
  37. qrCode: '', //当前扫描的二维码
  38. resetGo: false, //是否回到初始界面
  39. }
  40. },
  41. components: {
  42. footTool
  43. },
  44. methods: {
  45. //抢单后知道了
  46. know() {
  47. this.models.disjunctor = false;
  48. if (this.resetGo) {
  49. uni.navigateTo({
  50. url: `../settingCode/settingCode`,
  51. });
  52. }
  53. },
  54. //确定
  55. ok() {
  56. this.models.disjunctor = false;
  57. uni.showLoading({
  58. title: "加载中",
  59. mask: true,
  60. });
  61. if (this.settings[this.index].uniName == 'replaceSave') { //替换保存
  62. let postData = {
  63. "type": "update",
  64. "qrCode": this.qrCode,
  65. "destDept": this.options.targetId,
  66. "sourceDept": this.queryDept.id
  67. };
  68. post("/dept/scanChangeDept", postData).then((res) => {
  69. uni.hideLoading();
  70. let msg = "保存失败";
  71. let icon = "error";
  72. this.resetGo = false;
  73. if (res.status == 200) {
  74. this.resetGo = true;
  75. msg = "保存成功";
  76. icon = "success";
  77. }
  78. this.models = {
  79. disjunctor: true,
  80. content: msg,
  81. icon: icon,
  82. operate: {
  83. know: "知道了",
  84. },
  85. };
  86. })
  87. } else if (this.settings[this.index].uniName == 'settingSave') { //设置保存
  88. let postData = {
  89. "type": "save",
  90. "qrCode": this.qrCode,
  91. "destDept": this.options.targetId
  92. }
  93. post("/dept/scanChangeDept", postData).then((res) => {
  94. uni.hideLoading();
  95. let msg = "保存失败";
  96. let icon = "error";
  97. this.resetGo = false;
  98. if (res.status == 200) {
  99. this.resetGo = true;
  100. msg = "保存成功";
  101. icon = "success";
  102. }
  103. this.models = {
  104. disjunctor: true,
  105. content: msg,
  106. icon: icon,
  107. operate: {
  108. know: "知道了",
  109. },
  110. };
  111. })
  112. }
  113. },
  114. //取消
  115. cancel() {
  116. this.models.disjunctor = false;
  117. },
  118. // 底部按钮操作
  119. operate(i) {
  120. console.log(i,this.settings,'seimin')
  121. if (this.settings[i].uniName == 'replaceGo') { //替换,去选择科室
  122. uni.navigateTo({
  123. url: `../search/search?type=settingCode&uniName=${this.settings[i].uniName}&queryDept=${this.queryDept.dept}&queryDeptId=${this.queryDept.id}&qrCode=${this.qrCode}`,
  124. });
  125. } else if (this.settings[i].uniName == 'settingGo') { //设置,去选择科室
  126. uni.navigateTo({
  127. url: `../search/search?type=settingCode&uniName=${this.settings[i].uniName}&qrCode=${this.qrCode}`,
  128. });
  129. } else if (this.settings[i].uniName == 'replaceSave') { //替换保存
  130. this.index = i;
  131. this.models = {
  132. disjunctor: true,
  133. title: "提示",
  134. content: `此二维码绑定${this.options.targetDept}成功,${this.queryDept.dept}的二维码被清空`,
  135. icon: "warn",
  136. operate: {
  137. ok: "确定",
  138. cancel: "取消",
  139. },
  140. };
  141. } else if (this.settings[i].uniName == 'settingSave') { //设置保存
  142. this.index = i;
  143. this.models = {
  144. disjunctor: true,
  145. title: "提示",
  146. content: `将设置${this.options.targetDept}到此二维码上`,
  147. icon: "warn",
  148. operate: {
  149. ok: "确定",
  150. cancel: "取消",
  151. },
  152. };
  153. }
  154. },
  155. // 扫一扫
  156. drugsScanning() {
  157. SM().then((ress) => {
  158. this.qrCode = ress;
  159. let postData = {
  160. "type": "query",
  161. "qrCode": ress
  162. };
  163. uni.showLoading({
  164. title: "加载中",
  165. mask: true,
  166. });
  167. post("/dept/scanChangeDept", postData).then((res) => {
  168. uni.hideLoading();
  169. if (res.status == 200) {
  170. if (res.data) { //替换
  171. this.queryDept = {
  172. dept: res.data.dept,
  173. id: res.data.id
  174. };
  175. this.settings = [{
  176. name: '替换',
  177. uniName: 'replaceGo'
  178. }];
  179. } else { //设置
  180. this.queryDept = null;
  181. this.settings = [{
  182. name: '设置',
  183. uniName: 'settingGo'
  184. }];
  185. }
  186. } else {
  187. uni.showToast({
  188. icon: "none",
  189. title: "请求失败!",
  190. });
  191. }
  192. })
  193. });
  194. },
  195. },
  196. onLoad(options) {
  197. console.log(options,'seimin')
  198. this.options = options;
  199. if (options.uniName == "replaceGo") { //替换
  200. this.qrCode = options.qrCode
  201. this.queryDept = {
  202. dept: options.queryDept,
  203. id: options.queryDeptId
  204. };
  205. this.msg = `此二维码绑定${options.targetDept}成功,${this.queryDept.dept}的二维码被清空`;
  206. this.settings = [{
  207. name: '替换',
  208. uniName: 'replaceGo'
  209. }, {
  210. name: '保存',
  211. uniName: 'replaceSave'
  212. }];
  213. } else if (options.uniName == "settingGo") { //设置
  214. this.qrCode = options.qrCode;
  215. this.msg = `将设置${options.targetDept}到此二维码上`;
  216. this.settings = [{
  217. name: '设置',
  218. uniName: 'settingGo'
  219. }, {
  220. name: '保存',
  221. uniName: 'settingSave'
  222. }];
  223. }
  224. // #ifdef APP-PLUS
  225. webHandle("no", "app");
  226. // #endif
  227. // #ifdef H5
  228. webHandle("no", "wx");
  229. // #endif
  230. }
  231. }
  232. </script>
  233. <style lang="less" scoped>
  234. .settingCode {
  235. background-color: rgb(249, 250, 251);
  236. padding-top: 36rpx;
  237. height: 100vh;
  238. box-sizing: border-box;
  239. .scanning_btn {
  240. margin: 0 auto;
  241. width: 138rpx;
  242. height: 138rpx;
  243. background: #72c172;
  244. border-radius: 50%;
  245. /*偏移*/
  246. line-height: 200rpx;
  247. color: #fff;
  248. font-size: 36rpx;
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. text {
  253. font-size: 48rpx;
  254. }
  255. }
  256. .scanFont {
  257. font-size: 36rpx;
  258. font-weight: 700;
  259. margin: 32rpx;
  260. text-align: center;
  261. &.nr {
  262. font-weight: normal;
  263. }
  264. &.red {
  265. color: red;
  266. }
  267. }
  268. }
  269. </style>