processPosteriorSegment.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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="goBack">&#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="form">
  19. <view class="form-item">
  20. <div class="title">标签码</div>
  21. <div class="scan-card">
  22. <uni-easyinput v-model="form.qrCode" class="easyinput" @focus="handleInputFocus" type="text"
  23. placeholder="请扫描标签码" />
  24. <text class="font-icons" style="font-size: 20px;" @click="handleScanLabel">&#xe6b7;</text>
  25. </div>
  26. </view>
  27. <view class="form-item">
  28. <div class="title">员工码</div>
  29. <div class="scan-card">
  30. <uni-easyinput v-model="form.employee" class="easyinput" @focus="handleInputFocus" type="text"
  31. placeholder="请扫描员工码" />
  32. <text class="font-icons" style="font-size: 20px;" @click="handleScanEmployee">&#xe6b7;</text>
  33. </div>
  34. </view>
  35. <view class="form-item">
  36. <div class="title">不良数</div>
  37. <div class="content">
  38. <uni-easyinput v-model="form.badQty" @focus="handleInputFocus" placeholder="请输入不良数"
  39. type="digit" />
  40. </div>
  41. </view>
  42. <view class="form-item">
  43. <div class="title">不良类型</div>
  44. <div class="content">
  45. <uni-data-select v-model="form.badType" placeholder="请选择不良类型" :localdata="selectList" />
  46. </div>
  47. </view>
  48. <view class="form-item">
  49. <div class="title">班别</div>
  50. <div class="content">
  51. <uni-data-select v-model="form.classFlag" placeholder="请选择班别" :localdata="classFlagList" />
  52. </div>
  53. </view>
  54. </view>
  55. <view class="operationBtn">
  56. <button type="primary" style="width: calc(100% - 8px);margin: 0 4px;"
  57. @click="handleSubmitData">提交</button>
  58. </view>
  59. </template>
  60. </gui-page>
  61. </template>
  62. <script>
  63. import {
  64. ref,
  65. onMounted,
  66. defineComponent
  67. } from 'vue'
  68. export default defineComponent({
  69. setup(options) {
  70. const selectList = ref([]);
  71. const form = ref({
  72. hotPressId: '',
  73. qrCode: '',
  74. employee: '',
  75. badQty: 0,
  76. badType: '',
  77. classFlag: '',
  78. })
  79. onMounted(() => {
  80. form.value.hotPressId = options?.hotPressId ?? '';
  81. uni.$reqGet('getDictDataPage', {
  82. dictType: 'mes_inspection_type',
  83. })
  84. .then(({
  85. data
  86. }) => {
  87. selectList.value = []
  88. const dataList = data?.list ?? [];
  89. for (var i = 0; i < dataList.length; i++) {
  90. selectList.value.push({
  91. text: dataList[i].label,
  92. value: dataList[i].value,
  93. })
  94. }
  95. })
  96. })
  97. // 扫描标签码
  98. const handleScanLabel = function() {
  99. // #ifdef APP-PLUS
  100. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  101. mpaasScanModule.mpaasScan({
  102. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  103. 'scanType': ['qrCode', 'barCode'],
  104. // 是否隐藏相册,默认false不隐藏
  105. 'hideAlbum': false
  106. },
  107. (ret) => {
  108. if (ret.resp_code === 1000) {
  109. form.value.qrCode = ret.resp_result;
  110. }
  111. })
  112. // #endif
  113. }
  114. // 扫描员工码
  115. const handleScanEmployee = function() {
  116. // #ifdef APP-PLUS
  117. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  118. mpaasScanModule.mpaasScan({
  119. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  120. 'scanType': ['qrCode', 'barCode'],
  121. // 是否隐藏相册,默认false不隐藏
  122. 'hideAlbum': false
  123. },
  124. (ret) => {
  125. if (ret.resp_code === 1000) {
  126. form.value.employee = ret.resp_result;
  127. }
  128. })
  129. // #endif
  130. }
  131. const goBack = function() {
  132. uni.$goBack('/pages/workbranch/production/processExecution/processDetails')
  133. }
  134. // 保存
  135. const handleSubmitData = function() {
  136. const { qrCode, employee, classFlag } = form.value
  137. if (qrCode === '' || employee === '' || classFlag === '') {
  138. uni.showToast({
  139. title: msg,
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. return
  144. }
  145. uni.$reqPost('precessExecute', form.value)
  146. .then(({
  147. code,
  148. data,
  149. msg
  150. }) => {
  151. if (code === 0) {
  152. uni.showToast({
  153. title: '提交成功',
  154. icon: 'none',
  155. duration: 1000
  156. })
  157. setTimeout(() => {
  158. goBack()
  159. }, 1000)
  160. } else {
  161. uni.showToast({
  162. title: msg,
  163. icon: 'none',
  164. duration: 2000
  165. })
  166. }
  167. })
  168. }
  169. // 禁用软键盘
  170. const handleInputFocus = function() {
  171. // #ifdef APP-PLUS
  172. setTimeout(() => {
  173. uni.hideKeyboard()
  174. }, 100)
  175. // #endif
  176. }
  177. return {
  178. selectList,
  179. classFlagList: [{
  180. text: '白班',
  181. value: 0
  182. },
  183. {
  184. text: '晚班',
  185. value: 1
  186. }
  187. ],
  188. form,
  189. goBack,
  190. handleScanLabel,
  191. handleScanEmployee,
  192. handleInputFocus,
  193. handleSubmitData
  194. }
  195. }
  196. })
  197. </script>
  198. <style lang="scss" scoped>
  199. .gui-header-leader-btns {
  200. color: black;
  201. font-size: 24px !important;
  202. margin-left: 24rpx;
  203. }
  204. .list-content {
  205. background-color: #edeeee;
  206. }
  207. .form {
  208. margin-top: 80px;
  209. margin-bottom: 70px;
  210. font-size: 14px;
  211. padding: 4px 8px;
  212. border-radius: 4px;
  213. background-color: white;
  214. .form-title {
  215. height: 32px;
  216. line-height: 32px;
  217. text-align: center;
  218. font-size: 16px;
  219. font-weight: bold;
  220. border-bottom: 2px dashed #edeeee;
  221. }
  222. .form-item {
  223. .title {
  224. height: 32px;
  225. line-height: 32px;
  226. text-align: left;
  227. font-weight: bold;
  228. color: #333;
  229. }
  230. .content {
  231. height: 42px;
  232. line-height: 42px;
  233. margin: 0 0 6px 0;
  234. }
  235. .scan-card {
  236. width: 100%;
  237. position: relative;
  238. display: grid;
  239. grid-template-rows: 1fr;
  240. grid-template-columns: 1fr 30px;
  241. align-items: center;
  242. input {
  243. height: 35px;
  244. line-height: 35px;
  245. }
  246. text {
  247. // position: absolute;
  248. width: 30px;
  249. display: flex;
  250. justify-content: center;
  251. text-align: center;
  252. }
  253. }
  254. }
  255. }
  256. .font-icons {
  257. width: 40px;
  258. font-size: 20px;
  259. }
  260. .operationBtn {
  261. position: fixed;
  262. width: 100%;
  263. bottom: 0;
  264. padding: 12px 0;
  265. }
  266. </style>