settingCode.vue 8.1 KB

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