index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view>
  3. <view class="container">
  4. <view v-if="orderType!='OQC'&&orderType!='OQCRET'" style="position: fixed;top: 0;left:15px;right: 15px;z-index: 666;border-bottom: 1rpx solid #e0e0e0;">
  5. <tui-sel-load-list :maxCounts='5' typeName="生产班组" :disabled="false" :value="gcCode" title="选择生产班组"
  6. dotColor="#007aff" searchKey="" keyLabel="deptName" keyId="deptId" apiUrl="/product/whse/team/query"
  7. :postData="{}" @change="changeProItem">
  8. <uni-list-item showBorder showArrow title="生产班组" borderRight="0rpx" :rightText="gcName||'请选择生产班组'"
  9. link>
  10. </uni-list-item>
  11. </tui-sel-load-list>
  12. </view>
  13. <view v-if="orderType!='OQC'&&orderType!='OQCRET'" style="height: 30px;"></view>
  14. <tui-load-list ref="list" v-model="scaleList" apiUrl="/product/whse/parse/query" :postData={type:orderType}
  15. :limit="100">
  16. <scaleListCom @delete="deleteBtn" :scaleList="scaleList"></scaleListCom>
  17. </tui-load-list>
  18. <view style="height:100px"></view>
  19. <view class="fixedbombtn flex">
  20. <tui-button style="margin-right: 10rpx;" type="danger" class=" flex-1 margin-right-sm "
  21. @click="deleteBtn">清空</tui-button>
  22. <tui-button class=" flex-2 " @click="entry">{{butText}}</tui-button>
  23. </view>
  24. </view>
  25. <uni-fab ref="fab" :pattern="pattern" :horizontal="horizontal" :vertical="vertical" @fabClick="scan" />
  26. <!-- <tui-tabbar :tabBar="tabBar" :current="current" v-if="current>=0"></tui-tabbar> -->
  27. </view>
  28. </template>
  29. <script>
  30. import scaleListCom from '../scaleListCom.vue';
  31. import jweixin from 'weixin-js-sdk'
  32. import {
  33. parseAdd,
  34. whseAdd,
  35. whseTeam,
  36. whseRemove,
  37. whseRetAdd,
  38. getSign
  39. } from '@/api/whse.js'
  40. export default {
  41. components: {
  42. scaleListCom
  43. },
  44. data() {
  45. return {
  46. title: 'uni-fab',
  47. directionStr: '垂直',
  48. horizontal: 'right',
  49. vertical: 'bottom',
  50. direction: 'horizontal',
  51. orderType: null,
  52. getSign: getSign,
  53. gcCode: '',
  54. gcName: '',
  55. pattern: {
  56. color: '#7A7E83',
  57. backgroundColor: '#fff',
  58. selectedColor: '#007AFF',
  59. buttonColor: '#007AFF',
  60. iconColor: '#fff',
  61. icon: 'scan',
  62. },
  63. is_color_type: false,
  64. scaleList: [],
  65. current: 1,
  66. proTeam: [],
  67. proTeamid: [],
  68. butText: '入库',
  69. }
  70. },
  71. created() {
  72. this.getProTeam()
  73. this.getConfig()
  74. },
  75. onLoad(option) {
  76. // console.log(option, 'option')
  77. this.orderType = option.type
  78. var pageTitle = ''
  79. if (this.orderType == 'PRO') {
  80. pageTitle = '生产入库'
  81. this.butText = '入库'
  82. } else if (this.orderType == 'OQC') {
  83. pageTitle = '品检入库'
  84. this.butText = '入库'
  85. } else if (this.orderType == 'FTB') {
  86. pageTitle = '翻箱入库'
  87. this.butText = '入库'
  88. } else if (this.orderType == 'OQCRET') {
  89. pageTitle = '品检退库'
  90. this.butText = '退库'
  91. } else if (this.orderType == 'FTBRET') {
  92. pageTitle = '翻箱退库'
  93. this.butText = '退库'
  94. } else {
  95. this.butText = '入库'
  96. pageTitle = '生产入库'
  97. }
  98. uni.setNavigationBarTitle({
  99. title: pageTitle
  100. })
  101. // setTimeout(() => {
  102. // this.$refs.popup.open()
  103. // }, 300)
  104. },
  105. onPullDownRefresh() {
  106. uni.stopPullDownRefresh();
  107. this.$refs.list.loadData("rush")
  108. },
  109. onReachBottom() {
  110. this.$refs.list.loadData()
  111. },
  112. onPageScroll(e) {
  113. this.scrollTop = e.scrollTop;
  114. },
  115. methods: {
  116. changeProItem(e) {
  117. // console.log(e,'eee')
  118. this.proTeamids = []
  119. this.gcName = ''
  120. e.forEach((v, index) => {
  121. this.proTeamids.push(v.deptId)
  122. this.gcName += index > 0 ? ',' + v.deptName : v.deptName
  123. })
  124. // this.proTeamid = e.detail.value;
  125. },
  126. whseSucss() {
  127. this.$refs.list.loadData("rush")
  128. uni.hideLoading()
  129. this.$qsk.modal({
  130. title: this.butText + "成功",
  131. content: '',
  132. showCancel: false,
  133. confirmText: '确定'
  134. })
  135. },
  136. entry() {
  137. this.$qsk.modal({
  138. title: "您是否确认" + this.butText + "?",
  139. content: '',
  140. showCancel: true,
  141. confirmText: '确定'
  142. }).then(res2 => {
  143. const snCode = []
  144. this.scaleList.forEach(v => {
  145. snCode.push(v.snCode)
  146. })
  147. if (this.orderType == 'PRO' || this.orderType == 'OQC' || this.orderType == 'FTB') {
  148. const productWhseEntDet = []
  149. const aa = {
  150. teamIds: this.proTeamids,
  151. snCode: snCode
  152. }
  153. productWhseEntDet.push(aa)
  154. whseAdd({
  155. type: this.orderType,
  156. productWhseEntDet
  157. }).then(res => {
  158. this.whseSucss()
  159. }).catch(error => {
  160. uni.hideLoading()
  161. })
  162. } else {
  163. const retDets = []
  164. const aa = {
  165. teamIds: this.proTeamids,
  166. snCode: snCode
  167. }
  168. retDets.push(aa)
  169. whseRetAdd({
  170. type: this.orderType,
  171. retDets
  172. }).then(res => {
  173. this.whseSucss()
  174. }).catch(error => {
  175. uni.hideLoading()
  176. })
  177. }
  178. }).catch(() => {})
  179. },
  180. getConfig() {
  181. this.getSign({
  182. url: location.href,
  183. appid: 'wx2cfd24c7380cdc08',
  184. }).then(res => {
  185. var s = res.data
  186. jweixin.config({
  187. beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
  188. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  189. appId: s.appId, // 必填,公众号的唯一标识
  190. timestamp: s.timestamp, // 必填,生成签名的时间戳
  191. nonceStr: s.nonceStr, // 必填,生成签名的随机串
  192. signature: s.signature, // 必填,签名
  193. jsApiList: ['checkJsApi',"onMenushareTimeline",
  194. "onMenushareAppMessage",'scanQRCode'] // 必填,需要使用的JS接口列表
  195. })
  196. })
  197. },
  198. scan() {
  199. // parseAdd({
  200. // code: 'FP2-2-FF30-5-1',
  201. // type: this.orderType,
  202. // }).then(res => {
  203. // this.$refs.list.loadData("rush")
  204. // // uni.hideLoading()
  205. // // console.log(res,'res')
  206. // }).catch(error => {
  207. // // uni.hideLoading()
  208. // })
  209. const _this = this
  210. jweixin.scanQRCode({
  211. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  212. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  213. success: function(res) {
  214. console.log(res,'resss')
  215. let str = res.resultStr // 当needResult 为 1 时,扫码返回的结果
  216. parseAdd({code:res.resultStr,type: _this.orderType,}).then(res => {
  217. _this.$refs.list.loadData("rush")
  218. uni.hideLoading()
  219. // console.log(res,'res')
  220. }).catch(error => {
  221. uni.hideLoading()
  222. })
  223. },
  224. fail: (err) => {
  225. // console.error('扫描失败:' + err);
  226. uni.showToast({
  227. title: '扫描失败',
  228. icon: 'none'
  229. });
  230. }
  231. })
  232. },
  233. getProTeam() {
  234. uni.showLoading({
  235. title: '加载中'
  236. })
  237. // fixedAssetList({}).then(res => {
  238. // uni.hideLoading()
  239. // }).catch(error => {
  240. // uni.hideLoading()
  241. // })
  242. whseTeam().then(res => {
  243. this.proTeam = res.data
  244. uni.hideLoading()
  245. // console.log(res,'res')
  246. }).catch(error => {
  247. uni.hideLoading()
  248. })
  249. },
  250. deleteBtn(item) {
  251. let ids=[]
  252. let text='清空'
  253. if(item){
  254. ids.push(item.id)
  255. text="删除"
  256. }
  257. this.$qsk.modal({
  258. title: "您是否确认"+text+"数据?",
  259. content: '',
  260. showCancel: false,
  261. confirmText: '确定'
  262. }).then(res2 => {
  263. whseRemove({
  264. ids: ids,
  265. type: this.orderType
  266. }).then(res => {
  267. this.$refs.list.loadData("rush")
  268. })
  269. })
  270. },
  271. onchange(e) {
  272. const value = e.detail.value
  273. },
  274. onnodeclick(node) {},
  275. changeValue() {},
  276. dialogOpend() {
  277. this.$refs.alertDialog.open()
  278. },
  279. dialogClosed() {
  280. this.$refs.alertDialog.close()
  281. },
  282. getUpQMImg(val) {
  283. this.picList.forEach((v, index) => {
  284. if (v.categ == val.categ) {
  285. this.picList.splice(index, 1)
  286. return
  287. }
  288. })
  289. this.picList.push(val)
  290. },
  291. clecKListkHasItem(list, objName) {
  292. return list.some(item => item.categ == objName)
  293. },
  294. addAssetsBtn() {
  295. this.$tab.navigateTo('/pages/takestock/addAssets/index')
  296. },
  297. selectAssetsBtn() {
  298. this.$tab.navigateTo('/pages/takestock/assetsList/index')
  299. },
  300. }
  301. }
  302. </script>
  303. <style lang="scss">
  304. page {
  305. background-color: #ffffff;
  306. .container {
  307. padding: 30rpx;
  308. }
  309. }
  310. </style>