processFullInspection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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">全检工序【检验人:{{ employeeName }}】</text>
  11. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  12. <!-- 实际宽度请根据自己情况设置 -->
  13. <view style="width:40px;">
  14. <uni-easyinput v-model="scanNumber" type="text" class="hidden-focus" ref="scanRefs" focus
  15. @confirm="handleConfirmText" />
  16. </view>
  17. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  18. </view>
  19. </template>
  20. <template #gBody>
  21. <view class="form">
  22. <view class="form-item">
  23. <div class="title">不良数</div>
  24. <div class="content">
  25. <uni-easyinput v-model="badQty" @focus="handleInputFocus" placeholder="请输入不良数" type="digit" />
  26. </div>
  27. </view>
  28. <view class="form-item">
  29. <div class="title">不良类型</div>
  30. <div class="content">
  31. <uni-data-select v-model="badType" placeholder="请选择不良类型" :localdata="selectList" />
  32. </div>
  33. </view>
  34. <view class="form-item">
  35. <div class="title">班别</div>
  36. <div class="content">
  37. <uni-data-select v-model="classFlag" placeholder="请选择班别" :localdata="classFlagList" />
  38. </div>
  39. </view>
  40. <view class="table-title">
  41. <span>报工列表</span>
  42. </view>
  43. <view v-if="qrCodeList.length > 0" class="list-panel">
  44. <div v-for="(item, key) in qrCodeList" :key="key" class="panel">
  45. <uni-swipe-action>
  46. <!-- 基础用法 -->
  47. <uni-swipe-action-item :right-options="options" @click="handleRemoveQrCode(key)">
  48. <template #left>
  49. <view />
  50. </template>
  51. <div class="panel-row">
  52. <span>条码</span>
  53. <span>{{ item.labelContent }}</span>
  54. </div>
  55. <div class="panel-row">
  56. <span>物料编码</span>
  57. <span>{{ item.materialCode }}</span>
  58. </div>
  59. <div class="panel-row">
  60. <span>标签名称</span>
  61. <span>{{ item.labelName }}</span>
  62. </div>
  63. <div class="panel-row">
  64. <span>数量</span>
  65. <span>{{ item.qty }}{{ item.unitCode }}</span>
  66. </div>
  67. </uni-swipe-action-item>
  68. </uni-swipe-action>
  69. </div>
  70. </view>
  71. <view v-else>
  72. <view class="bg-image">
  73. <image src="@/static/empty.png" mode="heightFix" />
  74. <text>这里什么都没有...</text>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="operationBtn">
  79. <button type="primary" style="width: calc(100% - 8px);margin: 0 4px;"
  80. @click="handleSubmitData">提交</button>
  81. </view>
  82. <uni-popup ref="errorTip" type="dialog">
  83. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示" :content="errorTipMessage"
  84. @confirm="handleCloseErrorTipsModal" @close="handleCloseErrorTipsModal" />
  85. </uni-popup>
  86. </template>
  87. </gui-page>
  88. </template>
  89. <script>
  90. import {
  91. ref,
  92. reactive,
  93. toRefs,
  94. onMounted,
  95. defineComponent
  96. } from 'vue'
  97. export default defineComponent({
  98. setup(options) {
  99. const selectList = ref([]);
  100. // 隐藏输入框
  101. const scanRefs = ref()
  102. const form = reactive({
  103. scanNumber: '',
  104. employee: '',
  105. employeeName: null,
  106. badQty: 0,
  107. badType: null,
  108. classFlag: 0,
  109. qrCodeList: []
  110. })
  111. const errorState = ref(0)
  112. const errorTip = ref('')
  113. const errorTipMessage = ref('')
  114. const getList = function() {
  115. uni.$reqGet('getPersonalPageList', {
  116. processNo: 'INSPECTION',
  117. mesEmployeeMasterId: form.employee,
  118. })
  119. .then(async ({
  120. code,
  121. data,
  122. msg
  123. }) => {
  124. if (code === 0) {
  125. form.qrCodeList = data?.list ?? []
  126. } else {
  127. // #ifdef APP-PLUS
  128. plus.device.beep(2)
  129. // #endif
  130. errorTipMessage.value = msg
  131. errorTip.value.open()
  132. errorState.value = 0
  133. }
  134. })
  135. }
  136. onMounted(() => {
  137. uni.$reqGet('getDictDataPage', {
  138. dictType: 'mes_inspection_type',
  139. })
  140. .then(({
  141. data
  142. }) => {
  143. selectList.value = []
  144. const dataList = data?.list ?? [];
  145. for (var i = 0; i < dataList.length; i++) {
  146. selectList.value.push({
  147. text: dataList[i].label,
  148. value: dataList[i].value,
  149. })
  150. }
  151. })
  152. pollingFocus()
  153. // 每3s自动定位到扫码框
  154. setInterval(() => {
  155. pollingFocus()
  156. }, 3000)
  157. })
  158. const pollingFocus = function() {
  159. if (scanRefs.value.focusShow) {
  160. // #ifdef APP-PLUS
  161. setTimeout(() => {
  162. uni.hideKeyboard()
  163. }, 100)
  164. // #endif
  165. } else {
  166. scanRefs.value.onBlur()
  167. scanRefs.value.onFocus()
  168. }
  169. }
  170. const goHome = function() {
  171. uni.$goHome()
  172. }
  173. // 保存
  174. const handleSubmitData = function() {
  175. const submitParams = JSON.parse(JSON.stringify(form))
  176. submitParams.qrCodeList = []
  177. form.qrCodeList.forEach(ret => !ret.id ? submitParams.qrCodeList.push(ret.labelContent) : null)
  178. uni.$reqPost('inspectionExecute', submitParams)
  179. .then(({
  180. code,
  181. data,
  182. msg
  183. }) => {
  184. if (code === 0) {
  185. getList()
  186. uni.showToast({
  187. title: '提交成功',
  188. icon: 'none',
  189. duration: 1000
  190. })
  191. } else {
  192. uni.showToast({
  193. title: msg,
  194. icon: 'none',
  195. duration: 2000
  196. })
  197. }
  198. })
  199. }
  200. const handleRemoveQrCode = function(index) {
  201. form.qrCodeList.splice(index, 1)
  202. }
  203. const handleConfirmText = function(e) {
  204. // 扫码入库
  205. if (form.employee) {
  206. const fdIndex = form.qrCodeList.findIndex(ret => ret.labelContent === e)
  207. if ([null, '', undefined].includes(e)) {
  208. // #ifdef APP-PLUS
  209. plus.device.beep(2)
  210. // #endif
  211. errorTipMessage.value = '请扫入正确的条码!'
  212. errorTip.value.open()
  213. errorState.value = -1
  214. return
  215. }
  216. if (fdIndex != -1) {
  217. // #ifdef APP-PLUS
  218. plus.device.beep(2)
  219. // #endif
  220. errorTipMessage.value = '条码重复,请重新扫码!'
  221. errorTip.value.open()
  222. errorState.value = -1
  223. } else {
  224. // 存在员工码,扫码入列表
  225. uni.$reqGet("scanProcessFullInspectionBatchNumber", {
  226. batchNumber: e
  227. })
  228. .then(async ({
  229. code,
  230. data,
  231. msg
  232. }) => {
  233. if (code === 0) {
  234. // 绑定员工
  235. if (!!data) {
  236. form.qrCodeList.unshift({
  237. labelName: data?.materialName,
  238. materialCode: data?.erpMaterialNo,
  239. labelContent: e,
  240. unitCode: data?.unitCode,
  241. qty: data?.qty,
  242. })
  243. getList()
  244. }
  245. } else {
  246. // #ifdef APP-PLUS
  247. plus.device.beep(2)
  248. // #endif
  249. errorTipMessage.value = '员工码不正确,请检查!'
  250. errorTip.value.open()
  251. errorState.value = -1
  252. }
  253. })
  254. }
  255. setInputFocus()
  256. } else {
  257. uni.$reqGet("getEmployeeMaster", {
  258. id: e
  259. })
  260. .then(async ({
  261. code,
  262. data,
  263. msg
  264. }) => {
  265. if (code === 0) {
  266. // 绑定员工
  267. if (!!data) {
  268. form.employee = e
  269. form.employeeName = data.employeeName
  270. getList()
  271. }
  272. } else {
  273. // #ifdef APP-PLUS
  274. plus.device.beep(2)
  275. // #endif
  276. errorTipMessage.value = '员工码不正确,请检查!'
  277. errorTip.value.open()
  278. errorState.value = -1
  279. }
  280. })
  281. setInputFocus()
  282. }
  283. }
  284. const setInputFocus = function() {
  285. form.scanNumber = ''
  286. scanRefs.value.onBlur()
  287. scanRefs.value.onFocus()
  288. }
  289. // 禁用软键盘
  290. const handleInputFocus = function() {
  291. // #ifdef APP-PLUS
  292. setTimeout(() => {
  293. uni.hideKeyboard()
  294. }, 100)
  295. // #endif
  296. }
  297. return {
  298. selectList,
  299. ...toRefs(form),
  300. classFlagList: [{
  301. text: '白班',
  302. value: 0
  303. },
  304. {
  305. text: '晚班',
  306. value: 1
  307. }
  308. ],
  309. options: [{
  310. text: '删除',
  311. style: {
  312. backgroundColor: '#dd524d'
  313. }
  314. }],
  315. errorTip,
  316. errorTipMessage,
  317. goHome,
  318. scanRefs,
  319. handleInputFocus,
  320. handleConfirmText,
  321. handleSubmitData,
  322. handleRemoveQrCode
  323. }
  324. }
  325. })
  326. </script>
  327. <style lang="scss" scoped>
  328. .gui-header-leader-btns {
  329. color: black;
  330. font-size: 24px !important;
  331. margin-left: 24rpx;
  332. }
  333. span,
  334. text {
  335. font-size: 12px;
  336. }
  337. .list-content {
  338. background-color: #edeeee;
  339. }
  340. .form {
  341. margin-top: 80px;
  342. margin-bottom: 70px;
  343. font-size: 12px;
  344. border-radius: 4px;
  345. background-color: white;
  346. .form-title {
  347. height: 28px;
  348. line-height: 28px;
  349. text-align: center;
  350. font-size: 16px;
  351. font-weight: bold;
  352. border-bottom: 2px dashed #edeeee;
  353. }
  354. .form-item {
  355. padding: 2px 8px;
  356. .title {
  357. height: 28px;
  358. line-height: 28px;
  359. text-align: left;
  360. font-weight: bold;
  361. color: #333;
  362. }
  363. .content {
  364. height: 42px;
  365. line-height: 42px;
  366. margin: 0 0 6px 0;
  367. }
  368. .scan-card {
  369. width: 100%;
  370. position: relative;
  371. display: grid;
  372. grid-template-rows: 1fr;
  373. grid-template-columns: 1fr 30px;
  374. align-items: center;
  375. input {
  376. height: 35px;
  377. line-height: 35px;
  378. }
  379. text {
  380. // position: absolute;
  381. width: 30px;
  382. display: flex;
  383. justify-content: center;
  384. text-align: center;
  385. }
  386. }
  387. }
  388. }
  389. .font-icons {
  390. width: 40px;
  391. font-size: 20px;
  392. }
  393. .operationBtn {
  394. position: fixed;
  395. width: 100%;
  396. bottom: 0;
  397. padding: 12px 0;
  398. }
  399. .table-title {
  400. height: 28px;
  401. line-height: 28px;
  402. margin: -4px 0 3px 0;
  403. padding: 0 8px;
  404. font-size: 16px;
  405. font-weight: bold;
  406. background-color: white;
  407. }
  408. .hidden-focus {
  409. position: fixed;
  410. top: 0;
  411. left: 0;
  412. z-index: -1;
  413. opacity: 0;
  414. }
  415. </style>