package.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="content">
  3. <view class="topbar" v-show="isIphone">
  4. </view>
  5. <view class="status_bar">
  6. <view class="left" @click="goBack"><u-icon name="arrow-left"></u-icon>返回</view>
  7. <span style="font-size: 36rpx;">医废打包</span>
  8. <view class="right"></view>
  9. </view>
  10. <view class="mainCont">
  11. <u-cell-group style="margin-bottom: 10px">
  12. <u-cell-item :arrow="false">
  13. <view slot="title"><span class="red">*</span>科&emsp;&emsp;室:</view>
  14. {{ ks }}
  15. <u-icon @click="scanCode()" slot="right-icon" name="scan" color="#2979ff" size="40rpx"></u-icon>
  16. </u-cell-item>
  17. </u-cell-group>
  18. <u-cell-group style="margin-bottom: 10px">
  19. <u-cell-item>
  20. <view slot="title"><span class="red">*</span>医废类型:</view>
  21. <u-input input-align="right" disabled placeholder="请选择类型" v-model="yfType" type="text"
  22. @click="typeSelect = true" />
  23. </u-cell-item>
  24. <u-cell-item :arrow="false">
  25. <view slot="title"><span class="red">*</span>重&emsp;&emsp;量:</view>
  26. <view style="display: flex;justify-content: space-between;">
  27. <u-input input-align="right" placeholder="重量" v-model="weight" type="number"
  28. style="width: calc(100% - 30px);" />
  29. <span style='width: 30px;line-height: 35px;'>kg</span>
  30. </view>
  31. </u-cell-item>
  32. <u-cell-item :arrow="false">
  33. <view slot="title"><span class="red"></span>打&ensp;包&ensp;人:</view>
  34. {{ userName }}
  35. </u-cell-item>
  36. <u-cell-item :arrow="false">
  37. <view slot="title"><span class="red"></span>暂&ensp;存&ensp;点:</view>
  38. {{ positionName }}
  39. </u-cell-item>
  40. </u-cell-group>
  41. <view class="imgupload">
  42. <u-input placeholder="请输入备注内容" v-model="remark" auto-height type="textarea" />
  43. <u-upload :show-progress="false" ref="upload" @on-remove="uploadRemove" @on-success="uploadSuccess"
  44. :header="uploadHeader" max-count="3" width="80px" height="80px" :custom-btn="true" :action="action"
  45. :file-list="fileList">
  46. <view slot="addBtn" class="slot-btn">
  47. <image style="width: 80px;height: 80px" src="/static/tjzp.png" alt="">
  48. </view>
  49. </u-upload>
  50. </view>
  51. </view>
  52. <view class="bottomButton" @click="confirmShow()">
  53. <view>提交</view>
  54. </view>
  55. <u-select :default-value="selectType" value-name='code' @confirm="confirm" v-model="typeSelect"
  56. :list="typeList"></u-select>
  57. <u-toast ref="uToast" />
  58. <u-modal v-model="qrshow" @cancel="scanCode" @confirm="sumbitPack" show-cancel-button cancel-text="重新扫码"
  59. :content="ks" title="确认科室"></u-modal>
  60. <u-modal v-model="cgshow" @cancel="goBackWithClear" @confirm="continuePack" show-cancel-button
  61. content="提交成功,是否继续打包该科室的垃圾" title="提交成功"></u-modal>
  62. </view>
  63. </template>
  64. <script>
  65. const NET = require('@/utils/request')
  66. const API = require('@/config/api')
  67. export default {
  68. onLoad() {
  69. uni.getSystemInfo({
  70. success: (res) => {
  71. console.log(res)
  72. if (res.model == 'iPhone') {
  73. this.isIphone = true;
  74. }
  75. },
  76. fail: (err) => {
  77. console.log(err)
  78. }
  79. })
  80. let postData = {
  81. dictCode: 'rubbishCategoryHosp'
  82. }
  83. NET.request(API.getLabelByCode, postData).then(res => {
  84. console.log(res.data)
  85. this.typeList = res.data
  86. }).catch(error => {
  87. this.$refs.uToast.show({
  88. title: error.message,
  89. type: 'warning',
  90. })
  91. })
  92. NET.request(API.getUserInfoById, {}).then(res => {
  93. console.log(res.data)
  94. this.positionName = res.data.positionName;
  95. }).catch(error => {
  96. this.$refs.uToast.show({
  97. title: error.msg,
  98. type: 'warning',
  99. })
  100. })
  101. // alert(uni.getStorageSync('ksId'))
  102. this.ks = uni.getStorageSync('ksName');
  103. this.positionId = uni.getStorageSync('ksId')
  104. },
  105. onReady() {
  106. if (this.isIphone) {
  107. document.getElementsByClassName('mainCont')[0].style.height = document.getElementsByClassName('mainCont')[
  108. 0].clientHeight - 25 + 'px'
  109. }
  110. },
  111. onShow() {
  112. },
  113. data() {
  114. return {
  115. qrshow: false,
  116. cgshow: false,
  117. yfType: "",
  118. yfValue: "",
  119. selectType: [0],
  120. typeSelect: false,
  121. weight: 0,
  122. positionName: "",
  123. positionId: "",
  124. ks: "",
  125. ksId: "",
  126. typeList: [],
  127. remark: "",
  128. userName: uni.getStorageSync('userName'),
  129. isIphone: false,
  130. uploadHeader: {
  131. Authorization: 'Bearer ' + uni.getStorageSync('token')
  132. },
  133. action: API.uploadFile,
  134. fileList: [],
  135. imgList: [],
  136. }
  137. },
  138. methods: {
  139. uploadSuccess(data, index) {
  140. console.log(data, index)
  141. if (data.code == 200) {
  142. data.data[0].fileType = 2
  143. data.data[0].fileCategory = 1
  144. this.imgList.push(data.data[0])
  145. this.$refs.uToast.show({
  146. title: '上传成功',
  147. type: 'success',
  148. })
  149. } else {
  150. this.$refs.upload.remove(index)
  151. }
  152. },
  153. uploadRemove(index) {
  154. console.log(index);
  155. this.imgList.splice(index, 1)
  156. },
  157. goBack() {
  158. try {
  159. EbeiPlugins.onBackKeyDown();
  160. } catch (error) {
  161. uni.navigateBack({
  162. delta: 1
  163. });
  164. }
  165. // uni.navigateBack({
  166. // delta: 1
  167. // });
  168. },
  169. goBackWithClear() {
  170. uni.removeStorageSync('ksId')
  171. uni.removeStorageSync('ksName')
  172. uni.navigateBack({
  173. delta: 1
  174. });
  175. },
  176. confirm(val) {
  177. this.yfType = val[0].label
  178. this.yfValue = val[0].value
  179. this.selectType[0] = this.typeList.findIndex((a) => a.code == val[0].value)
  180. },
  181. getKs() {
  182. NET.request(API.queryPositionDetail + '/' + this.positionId, {}).then(res => {
  183. if (res.data.positionType == '1') {
  184. uni.setStorage({
  185. key: 'ksId',
  186. data: this.positionId
  187. })
  188. uni.setStorage({
  189. key: 'ksName',
  190. data: res.data.positionName
  191. })
  192. this.ks = res.data.positionName
  193. } else {
  194. this.$refs.uToast.show({
  195. title: '此点位不是科室,请重新扫码',
  196. type: 'warning',
  197. })
  198. }
  199. }).catch(error => {
  200. this.$refs.uToast.show({
  201. title: error.msg,
  202. type: 'warning',
  203. })
  204. })
  205. },
  206. scanCode() {
  207. console.log('asdasdasd')
  208. let that = this
  209. EbeiPlugins.scanQRCode((string) => {
  210. that.positionId = string;
  211. that.getKs()
  212. }, () => {
  213. that.showTips('扫码失败')
  214. })
  215. },
  216. confirmShow() {
  217. if (!this.positionId) {
  218. this.$refs.uToast.show({
  219. title: '请扫码获取科室',
  220. type: 'warning',
  221. })
  222. return false
  223. }
  224. if (!this.yfValue) {
  225. this.$refs.uToast.show({
  226. title: '请选择医废类型',
  227. type: 'warning',
  228. })
  229. return false
  230. }
  231. if (!this.weight) {
  232. this.$refs.uToast.show({
  233. title: '请输入重量',
  234. type: 'warning',
  235. })
  236. return false
  237. }
  238. this.qrshow = true;
  239. },
  240. continuePack() {
  241. this.weight = 0;
  242. this.remark = '';
  243. this.$refs.upload.clear()
  244. this.imgList = [];
  245. this.yfType = "";
  246. this.yfValue = "";
  247. },
  248. sumbitPack() {
  249. let postData = {
  250. packRemake: this.remark,
  251. fileList: this.imgList,
  252. createUser: uni.getStorageSync('userId'),
  253. positionId: this.positionId, //科室ID
  254. rubbishCategory: this.yfValue, //医废类型
  255. packWeight: this.weight,
  256. }
  257. NET.request(API.SaveOrUpdatePackage, postData, 'POST').then(res => {
  258. console.log(res.data)
  259. this.cgshow = true;
  260. }).catch(error => {
  261. this.$refs.uToast.show({
  262. title: error.msg,
  263. type: 'warning',
  264. })
  265. })
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss">
  271. .mainCont {
  272. height: calc(100% - 80rpx);
  273. padding-bottom: 60px;
  274. overflow-y: scroll;
  275. }
  276. .red {
  277. display: inline-block;
  278. width: 10px;
  279. height: 10px;
  280. color: red;
  281. }
  282. .imgupload {
  283. padding: 10px;
  284. background: #fff;
  285. }
  286. /deep/ .u-cell__value {
  287. color: #1c1c1c;
  288. }
  289. </style>