current.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="app-container">
  3. <view class="top-view" style="height: calc(50% - 37px); padding-top: 20px;">
  4. <scroll-view scroll-y="true" class="top-scrollview" >
  5. <view>
  6. <view style="display: flex;">
  7. <view class="detailV">{{title}}</view>
  8. </view>
  9. </view>
  10. <view v-for="(value, key) in titleData" :key="key">
  11. <view style="display: flex;">
  12. <view class="titleV">{{key}}:</view>
  13. <view class="detailV" v-bind:style="isQuery(key)" @click="queryList(key,value)">{{value}}</view>
  14. </view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. <view class="mid-table" style="height: calc(50% - 57px);">
  19. <zb-table
  20. ref="zbTable"
  21. :show-header="true"
  22. :stripe="false"
  23. :columns="column"
  24. :data="data"
  25. :highlight="true"
  26. @currentChange="currentChange"
  27. :border="true"
  28. :fit="true"
  29. >
  30. </zb-table>
  31. </view>
  32. <view class="bottom-view" style="height: 84px;">
  33. <uni-forms
  34. :value="formData"
  35. ref="form"
  36. validate-trigger="submit"
  37. >
  38. <view style="position: relative;display: flex;flex-direction: row;align-items: center;height:37px;width:100%">
  39. <text style="width: 40px;font-size: 14px;color: #606266;">仓库</text>
  40. <button size="mini" type="default" @click="searchIconClick('ware')" style="width: calc(100% - 106px)" v-if="formData.warehouseName">{{ formData.warehouseName }}</button>
  41. <button size="mini" type="default" @click="searchIconClick('ware')" style="width: calc(100% - 106px)" v-if="!formData.warehouseName">选择仓库</button>
  42. <button size="mini" type="primary" @click="handleBack">返回</button>
  43. </view>
  44. <uni-forms-item name="remark" label="条码" labelAlign="right" :labelWidth="40">
  45. <uni-easyinput type="text" :inputBorder="true" v-model="barCode" :clearable="false">
  46. <template #right>
  47. <button size="mini" type="default" @click="handleScanClick" style="margin-right:5px;">
  48. <uni-icons type="scan" size="15"></uni-icons>
  49. </button>
  50. <button size="mini" type="primary" @click="getList">查询</button>
  51. </template>
  52. </uni-easyinput>
  53. </uni-forms-item>
  54. </uni-forms>
  55. </view>
  56. <scan-code />
  57. <!-- 仓库 -->
  58. <WarePopup ref="WarePopup" :title="'仓库'" :idxFlag="'ware'" @sendData="getSendData"/>
  59. </view>
  60. </template>
  61. <script>
  62. import { getDicts } from "@/api/system/dict/data"; // 字典
  63. import scanCode from "@/components/scan/scan.vue";
  64. import WarePopup from './popup/commonpopup.vue' // 仓库
  65. import { currentStock, listWarehouse } from '@/api/wms/report.js'
  66. export default {
  67. components: {
  68. scanCode,
  69. WarePopup,
  70. },
  71. onBackPress(options) {
  72. if (options.from === 'navigateBack') {
  73. // 来自于导航条返回按钮或者系统返回按钮的事件
  74. return false;
  75. }
  76. // 双击返回的逻辑
  77. const now = Date.now();
  78. if (this.lastBackPress && now - this.lastBackPress < 1000) {
  79. // 如果两次点击的间隔小于1000毫秒,则可以认为是双击
  80. //这时退出
  81. return false;
  82. } else {
  83. this.lastBackPress = now;
  84. uni.showToast({
  85. title: '再按一次退出',
  86. icon: 'none'
  87. });
  88. setTimeout(() => {
  89. this.lastBackPress = null;
  90. }, 1000);
  91. return true;
  92. }
  93. },
  94. data() {
  95. return {
  96. column: [ // 表头数据
  97. { name: 'materialCode', label:'物料', align:'center', emptyString:'--' },
  98. { name: 'labelCode', label:'标签', align:'center', emptyString:'--' },
  99. { name: 'stockQty', label:'数量', align:'center', emptyString:'--' },
  100. { name: 'unitName', label:'单位', align:'center', emptyString:'--' },
  101. { name: 'materialSpecification', label:'规格', align:'center', emptyString:'--' },
  102. { name: 'warehouseName', label:'仓库', align:'center', emptyString:'--' },
  103. { name: 'locationName', label:'货位', align:'center', emptyString:'--' }
  104. ],
  105. data: [], // 表体数据
  106. title: '', // title: '【4/14】',
  107. titleData: {},
  108. formData: {
  109. warehouseCode: '',
  110. warehouseName: '',
  111. },
  112. barCode:"", //条码
  113. };
  114. },
  115. created() {},
  116. methods:{
  117. onShow() { //安卓扫码
  118. let that = this;
  119. uni.$off("scancode"); // 每次进来先 移除全局自定义事件监听器
  120. uni.$on("scancode", (data) => {
  121. // 扫描PCS码
  122. if(data && data !== ''){
  123. data = data.replace(/^\s+|\s+$/g, '');
  124. that.barCode = data;
  125. that.getList();
  126. }else{
  127. uni.showToast({
  128. title: '扫码失败!',
  129. icon:'none',
  130. duration: 2000
  131. });
  132. }
  133. });
  134. },
  135. getScanCkList(barCode){//仓库扫码请求
  136. let that = this;
  137. let params = {
  138. status: "0", // (固定)
  139. params: {
  140. "barCode":barCode,
  141. "limit":1
  142. },
  143. }
  144. // 仓库网络请求
  145. listWarehouse(params).then(res => {
  146. if(res.code === 200){
  147. let data = res.rows ? res.rows[0] : {};
  148. if(data && Object.keys(data).length !== 0){
  149. that.formData.warehouseCode = data.warehouseCode;
  150. that.formData.warehouseName = data.warehouseName;
  151. }
  152. }
  153. });
  154. },
  155. currentChange(row, index){//行点击
  156. let tmpData = {
  157. "编码": row.materialCode,
  158. "品名": row.materialName,
  159. "仓库": row.warehouseName,
  160. "货位": row.locationName,
  161. "数量": row.stockQty,
  162. "单位": row.unitName,
  163. "规格": row.materialSpecification,
  164. "托码": row.palletCode,
  165. "包装码": row.packageCode,
  166. "批号": row.batch,
  167. "批号1": row.batch1,
  168. "批号2": row.batch2
  169. }
  170. this.titleData = tmpData;
  171. this.title = '【'+ (index+1) + '/' + this.data.length +'】'
  172. },
  173. isQuery(key){
  174. let style='';
  175. if(key == '编码'){
  176. style = 'color:blue'
  177. }
  178. return style;
  179. },
  180. //蓝字点击事件
  181. queryList(key,value){
  182. if(key == '编码'){
  183. key = 'materialCode'
  184. }else{
  185. key = null;
  186. }
  187. if(key){
  188. this.getList(key,value)
  189. }
  190. },
  191. getList(key,value){
  192. let that = this;
  193. let queryParams = {
  194. params:{"limit": 200},
  195. "reportType": "01",
  196. "warehouseCode": this.formData.warehouseCode == '00' ? null : this.formData.warehouseCode
  197. };
  198. //如果有传参,将键值赋值给查询
  199. if(key && value){
  200. queryParams[key] = value;
  201. }
  202. //处理条码
  203. let splitPre = this.barCode.split("|")[0];
  204. let splitLast = this.barCode.slice(splitPre.length+1);
  205. if(splitPre=='WH'){//仓库
  206. queryParams.warehouseCode = splitLast;
  207. this.getScanCkList(splitLast);
  208. }
  209. if(splitPre=='PT'){//货位
  210. queryParams.locationCode = splitLast;
  211. }
  212. if(splitPre=='L'){//标签
  213. queryParams.labelCode = splitLast;
  214. }
  215. uni.showToast({
  216. title: '查询库存中,稍等...',
  217. icon:'none',
  218. duration: 2000
  219. });
  220. //查询
  221. currentStock(queryParams).then(res => {
  222. if(res.code === 200){
  223. that.data = res.rows;
  224. that.title = "返回数据" + res.rows.length + "行";
  225. }
  226. //qthis.data = res;
  227. })
  228. },
  229. handleBack(){ //返回
  230. uni.showModal({
  231. title: '提示',
  232. content: '确认返回?',
  233. success: function (res) {
  234. if (res.confirm) {
  235. uni.navigateBack();
  236. } else if (res.cancel) {
  237. }
  238. }
  239. });
  240. },
  241. searchIconClick(type){// 基础资料按钮
  242. switch (type){
  243. case "ware": // 仓库
  244. this.$refs.WarePopup.showPopup();
  245. break;
  246. default:
  247. break;
  248. }
  249. },
  250. getSendData(res){ //基础资料
  251. let cFlag = res.currentFlag;
  252. switch (cFlag){
  253. case "ware": // 仓库
  254. this.formData.warehouseCode = res.selectData.warehouseCode;
  255. this.formData.warehouseName = res.selectData.warehouseName;
  256. break;
  257. default:
  258. break;
  259. }
  260. },
  261. // 条码右侧扫码按钮事件
  262. handleScanClick:function(){
  263. let that = this;
  264. uni.scanCode({
  265. success: function(res) {
  266. // {"scanType":"QR_CODE","path":"","charSet":"ISO8859_1","result":"PT|04-A-1-1","errMsg":"scanCode:ok"}
  267. if(res.errMsg == "scanCode:ok"){
  268. that.barCode = res.result;
  269. that.getList();
  270. }else{
  271. uni.showToast({
  272. title: '扫码失败!',
  273. icon:'none',
  274. duration: 2000
  275. });
  276. }
  277. },
  278. fail: (err) => {
  279. //扫码失败
  280. },
  281. complete: () => {
  282. //扫码结束
  283. }
  284. });
  285. },
  286. },
  287. }
  288. </script>
  289. <style lang="less">
  290. .app-container{
  291. height: 100vh;
  292. }
  293. .top-view{
  294. padding: 3px 3px 3px 3px;
  295. background-color: '#ffffff';
  296. height: 33vh;
  297. .top-scrollview{
  298. // height: calc(50vh - 70px);
  299. height: 100%;
  300. background: white;
  301. padding: 5px;
  302. }
  303. .titleV {
  304. color: #888888;
  305. font-size: 12px;
  306. height: 18px;
  307. line-height: 18px;
  308. text-align: left;
  309. width: 50px;
  310. // width: auto !important;
  311. }
  312. .detailV {
  313. margin-left: 4px;
  314. color: #333333;
  315. font-size: 13px;
  316. height: 18px;
  317. line-height: 18px;
  318. width: calc(100vw - 40px);
  319. // width: auto !important;;
  320. }
  321. }
  322. .mid-table{
  323. padding: 0px 3px 0px 3px;
  324. /* #ifndef APP-PLUS */
  325. height: calc(50vh - 46px);
  326. /* #endif */
  327. /* #ifdef APP-PLUS */
  328. height: calc(50vh - 55px);
  329. /* #endif */
  330. // background-color: chocolate;
  331. }
  332. ::v-deep .zb-table-body{
  333. /* #ifndef APP-PLUS */
  334. height: calc(50vh - 70px) !important;
  335. /* #endif */
  336. /* #ifdef APP-PLUS */
  337. height: calc(50vh - 80px) !important;
  338. /* #endif */
  339. }
  340. .bottom-view{
  341. padding: 3px;
  342. // background-color: rebeccapurple;
  343. }
  344. ::v-deep .zb-table .item-td{
  345. height: 25px!important;
  346. line-height: 25px!important;
  347. }
  348. ::v-deep .zb-table .zb-table-header{
  349. height: 25px!important;;
  350. }
  351. ::v-deep .zb-table .zb-table-header .item-th{
  352. line-height: 25px!important;;
  353. height: 25px!important;;
  354. }
  355. .icon {
  356. position: absolute;
  357. top: 10px;
  358. right: 10px;
  359. width: 20px;
  360. height: 20px;
  361. cursor: pointer;
  362. }
  363. ::v-deep .uni-forms-item__label{
  364. justify-content: flex-end !important;
  365. }
  366. ::v-deep .uni-forms-item{
  367. margin-bottom: 1px !important;
  368. }
  369. ::v-deep .is-disabled {
  370. color: black !important;
  371. }
  372. //去掉button的边框
  373. uni-button:after {
  374. border: none;
  375. }
  376. </style>