settingCode.vue 8.9 KB

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