cuttingList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
  7. @tap="goHome">&#xe6c5;</text>
  8. <!-- 导航文本此处也可以是其他自定义内容 -->
  9. <text
  10. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text">分切任务单</text>
  11. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  12. <!-- 实际宽度请根据自己情况设置 -->
  13. <view style="width:40px;" />
  14. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  15. </view>
  16. </template>
  17. <template #gBody>
  18. <view class="list-content">
  19. <view class="scan">
  20. <view class="scan-card">
  21. <uni-easyinput ref="easyinput" v-model="scanBatchNumber" :input-border="false"
  22. :clearable="false" type="text" focus @focus="handleInputFocus" placeholder="请扫描来源批次号"
  23. @confirm="confirmBatchNumber" />
  24. <text class="font-icons" style="font-size: 20px;" @click="handleMapass">&#xe6b7;</text>
  25. </view>
  26. </view>
  27. <view class="tabs">
  28. <div class="tabs-list">
  29. <text :class="[checkedTabs===0?'tabs-item-active':'tabs-item']"
  30. @click="handleCheckTabs(0)">待分切</text>
  31. <text :class="[checkedTabs===1?'tabs-item-active':'tabs-item']"
  32. @click="handleCheckTabs(1)">任务中</text>
  33. <text :class="[checkedTabs===2?'tabs-item-active':'tabs-item']"
  34. @click="handleCheckTabs(2)">已完成</text>
  35. </div>
  36. </view>
  37. <view v-if="cardList?.length > 0" class="list-panel">
  38. <view v-for="item in cardList" :key="item.id" class="panel" @click="handleToScanMaterials(item)">
  39. <view class="panel-row">
  40. <text>{{ item.ebillNo }}</text>
  41. <text v-if="checkedTabs===0 || checkedTabs===2" class="text-2 font-icons">分切&#xe66b;</text>
  42. </view>
  43. <view class="panel-row">
  44. <text>创建人</text>
  45. <text>{{ item.creator }}</text>
  46. </view>
  47. <view class="panel-row">
  48. <text>创建时间</text>
  49. <text>{{ $parseTime(item.createTime) }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. <view v-else>
  54. <view class="bg-image">
  55. <image src="@/static/empty.png" mode="heightFix" />
  56. <text>这里什么都没有...</text>
  57. </view>
  58. </view>
  59. </view>
  60. <uni-popup ref="errorTip" type="dialog">
  61. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示" :content="errorTipMessage"
  62. @confirm="handleCloseErrorTipsModal" @close="handleCloseErrorTipsModal" />
  63. </uni-popup>
  64. </template>
  65. </gui-page>
  66. </template>
  67. <script>
  68. import {
  69. onReachBottom
  70. } from '@dcloudio/uni-app'
  71. import {
  72. ref,
  73. defineComponent,
  74. computed,
  75. onMounted
  76. } from 'vue'
  77. export default defineComponent({
  78. setup() {
  79. const errorState = ref(0)
  80. const easyinput = ref()
  81. const errorTip = ref('')
  82. const errorTipMessage = ref('')
  83. const scanBatchNumber = ref('')
  84. const checkedTabs = ref(0)
  85. const queryParams = ref({
  86. pageSize: 8,
  87. pageNo: 1,
  88. slitStatus: 0
  89. })
  90. const cardList = ref([])
  91. onMounted(() => {
  92. search()
  93. })
  94. const search = function() {
  95. uni.$reqGet('getCuttingList', queryParams.value)
  96. .then(({
  97. data,
  98. msg
  99. }) => {
  100. cardList.value = data?.list ?? []
  101. })
  102. }
  103. const goHome = function() {
  104. uni.$goHome()
  105. }
  106. const handleToScanMaterials = function(params) {
  107. uni.navigateTo({
  108. url: `/pages/workbranch/production/cutting/cuttingCheckout?params=${JSON.stringify(params)}`
  109. })
  110. }
  111. const handleCheckTabs = function(item) {
  112. switch (item) {
  113. case 0:
  114. queryParams.value.slitStatus = 0
  115. break
  116. case 1:
  117. queryParams.value.slitStatus = 1
  118. break
  119. case 2:
  120. queryParams.value.slitStatus = 2
  121. break
  122. }
  123. queryParams.value.pageNo = 1
  124. checkedTabs.value = item
  125. search()
  126. }
  127. const handleMapass = function() {
  128. // #ifdef APP-PLUS
  129. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  130. mpaasScanModule.mpaasScan({
  131. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  132. 'scanType': ['qrCode', 'barCode'],
  133. // 是否隐藏相册,默认false不隐藏
  134. 'hideAlbum': false
  135. },
  136. (ret) => {
  137. if (ret.resp_code === 1000) {
  138. uni.$reqGet('scanOrderNo', {
  139. qrCode: ret.resp_result
  140. })
  141. .then(({
  142. data,
  143. msg
  144. }) => {
  145. if (data != null && Object.keys(data).length > 0) {
  146. uni.navigateTo({
  147. url: `/pages/workbranch/production/cutting/cuttingCheckout?params=${JSON.stringify({ ...data, qrCode: ret.resp_result })}`
  148. })
  149. } else {
  150. // #ifdef APP-PLUS
  151. plus.device.beep(2)
  152. // #endif
  153. errorTipMessage.value = '此来源批次号不正确!'
  154. errorTip.value.open()
  155. errorState.value = 0
  156. }
  157. })
  158. }
  159. })
  160. // #endif
  161. // #ifdef H5
  162. uni.$reqGet('scanOrderNo', {
  163. qrCode: '20230630000013-0001-001'
  164. })
  165. .then(({
  166. code,
  167. data,
  168. msg
  169. }) => {
  170. if (data != null && Object.keys(data).length > 0) {
  171. uni.navigateTo({
  172. url: `/pages/workbranch/production/cutting/cuttingCheckout?params=${JSON.stringify({ ...data, qrCode: '20230630000013-0001-001' })}`
  173. })
  174. } else {
  175. // #ifdef APP-PLUS
  176. plus.device.beep(2)
  177. // #endif
  178. errorTipMessage.value = '此来源批次号不正确!'
  179. errorTip.value.open()
  180. errorState.value = 0
  181. }
  182. })
  183. // #endif
  184. }
  185. const confirmBatchNumber = function(e) {
  186. uni.$reqGet('scanOrderNo', {
  187. qrCode: e
  188. })
  189. .then(({
  190. code,
  191. data,
  192. msg
  193. }) => {
  194. if (data != null && Object.keys(data).length > 0) {
  195. uni.navigateTo({
  196. url: `/pages/workbranch/production/cutting/cuttingCheckout?params=${JSON.stringify({ ...data, qrCode: e })}`
  197. })
  198. } else {
  199. // #ifdef APP-PLUS
  200. plus.device.beep(2)
  201. // #endif
  202. errorTipMessage.value = '此来源批次号不正确!'
  203. errorTip.value.open()
  204. errorState.value = 0
  205. }
  206. })
  207. }
  208. const setInputFocus = function() {
  209. scanBatchNumber.value = ''
  210. easyinput.value.onBlur()
  211. easyinput.value.onFocus()
  212. }
  213. // 关闭错误信息弹窗
  214. const handleCloseErrorTipsModal = async function() {
  215. errorTip.value.close()
  216. if (errorState.value === 0) {
  217. await setInputFocus()
  218. }
  219. }
  220. // 禁用软键盘
  221. const handleInputFocus = function() {
  222. setTimeout(() => {
  223. uni.hideKeyboard()
  224. }, 100)
  225. }
  226. // uniapp移动端触底事件
  227. onReachBottom(() => {
  228. queryParams.value.pageNo += 1
  229. uni.$reqGet('getCuttingList', queryParams.value)
  230. .then(({
  231. data
  232. }) => {
  233. Array.prototype.push.call(cardList.value, ...data?.list ?? [])
  234. })
  235. })
  236. return {
  237. goHome,
  238. cardList,
  239. checkedTabs,
  240. easyinput,
  241. errorState,
  242. errorTip,
  243. errorTipMessage,
  244. scanBatchNumber,
  245. handleInputFocus,
  246. handleMapass,
  247. handleCheckTabs,
  248. confirmBatchNumber,
  249. handleToScanMaterials,
  250. handleCloseErrorTipsModal
  251. }
  252. }
  253. })
  254. </script>
  255. <style lang="scss" scoped>
  256. .gui-header-leader-btns {
  257. color: black;
  258. font-size: 24px !important;
  259. margin-left: 24rpx;
  260. }
  261. .list-content {
  262. margin-top: 80px;
  263. background-color: #edeeee;
  264. }
  265. .tabs {
  266. position: fixed;
  267. top: 72px;
  268. left: 0;
  269. width: 100%;
  270. height: 45px;
  271. display: flex;
  272. align-items: flex-end;
  273. padding: 0 2px;
  274. z-index: 9;
  275. background-color: white;
  276. .tabs-list {
  277. border-radius: 3px;
  278. overflow: hidden;
  279. }
  280. .tabs-item {
  281. display: inline-block;
  282. width: 60px;
  283. height: 30px;
  284. line-height: 30px;
  285. padding: 0 8px;
  286. font-size: 14px;
  287. font-weight: bold;
  288. text-align: center;
  289. color: black;
  290. border-bottom: 1.5px dashed #00a0e9;
  291. transition: all .5s ease-in-out;
  292. }
  293. .tabs-item-active {
  294. position: relative;
  295. display: inline-block;
  296. width: 60px;
  297. height: 30px;
  298. line-height: 30px;
  299. padding: 0 8px;
  300. font-size: 14px;
  301. font-weight: bold;
  302. text-align: center;
  303. color: white;
  304. border-left: 1px solid #00a0e9;
  305. border-top: 1px solid #00a0e9;
  306. border-right: 1px solid #00a0e9;
  307. border-bottom: 1.5px solid #00a0e9;
  308. border-radius: 5px 5px 0 0;
  309. animation: .3s linear show;
  310. background-color: #00a0e9;
  311. }
  312. .tabs-item-active::before {
  313. content: '';
  314. position: absolute;
  315. left: -10px;
  316. bottom: 0;
  317. width: 10px;
  318. height: 10px;
  319. background: radial-gradient(circle at 0% 25%, transparent 10px, #00a0e9 0)
  320. }
  321. .tabs-item-active::after {
  322. content: '';
  323. position: absolute;
  324. right: -10px;
  325. bottom: 0;
  326. width: 10px;
  327. height: 10px;
  328. background: radial-gradient(circle at 100% 25%, transparent 10px, #00a0e9 0)
  329. }
  330. }
  331. @keyframes show {
  332. from {
  333. transform: translateY(5%);
  334. }
  335. to {
  336. transform: translateY(0%);
  337. }
  338. }
  339. .list-panel {
  340. padding: 5px 8px;
  341. margin-top: 92px;
  342. overflow-y: scroll;
  343. }
  344. .scan {
  345. position: fixed;
  346. top: 116px;
  347. left: 0;
  348. height: 45px;
  349. width: calc(100% - 24px);
  350. padding: 0 12px;
  351. display: flex;
  352. justify-content: space-between;
  353. align-items: center;
  354. border-top: 1px solid #edeeee;
  355. border-bottom: 1px solid #edeeee;
  356. z-index: 9;
  357. background-color: white;
  358. .scan-card {
  359. width: 100%;
  360. display: grid;
  361. grid-template-rows: 1fr;
  362. grid-template-columns: 7fr 2fr;
  363. align-items: center;
  364. input {
  365. height: 35px;
  366. line-height: 35px;
  367. }
  368. text {
  369. width: 100%;
  370. text-align: right;
  371. }
  372. }
  373. }
  374. </style>