materialInputRegister.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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="list-content">
  19. <view class="scan">
  20. <view class="scan-card">
  21. <uni-easyinput ref="easyinput" v-model="scanNumber" :input-border="false" :clearable="false"
  22. type="text" focus placeholder="扫描采购单号 / 供应商" @focus="handleInputFocus"
  23. @confirm="handleKeydown" />
  24. <text class="font-icons icon-scan" @click="handleMapass">&#xe6b7;</text>
  25. </view>
  26. </view>
  27. <view class="collapsed-panel" v-if="purchaseOrderList?.length > 0">
  28. <view class="panel" v-for="item in purchaseOrderList">
  29. <uni-collapse>
  30. <uni-collapse-item open :show-animation="true">
  31. <template v-slot:title>
  32. <div class="top">
  33. <div class="panel-row">
  34. <span>采购单</span>
  35. <span>{{ item.erpOrderNo }}</span>
  36. </div>
  37. <div class="panel-row">
  38. <span>供应商</span>
  39. <span>{{ item.supplierName }}</span>
  40. </div>
  41. </div>
  42. </template>
  43. <div class="content" v-for="detail in item?.detail"
  44. @click="handleNavigateToInfoDetail(item, detail)">
  45. <div class="panel-row">
  46. <span>物料编码</span>
  47. <span>{{ detail.materialNo }}</span>
  48. </div>
  49. <div class="panel-row">
  50. <span>采购数量</span>
  51. <span>{{ detail.materialQty }}</span>
  52. </div>
  53. <span class="font-icons">&#xe66b;</span>
  54. </div>
  55. </uni-collapse-item>
  56. </uni-collapse>
  57. </view>
  58. </view>
  59. <view v-else>
  60. <view class="bg-image">
  61. <image src="@/static/empty.png" mode="heightFix" />
  62. <text>这里什么都没有...</text>
  63. </view>
  64. </view>
  65. </view>
  66. <uni-popup ref="errorTip" type="dialog">
  67. <uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示" :content="errorTipMessage"
  68. @confirm="handleCloseErrorTipsModal" @close="handleCloseErrorTipsModal" />
  69. </uni-popup>
  70. </template>
  71. </gui-page>
  72. </template>
  73. <script>
  74. import {
  75. defineComponent,
  76. onBeforeMount,
  77. ref
  78. } from 'vue'
  79. export default defineComponent({
  80. setup() {
  81. const modalForm = ref('')
  82. const errorState = ref(0)
  83. const easyinput = ref()
  84. const errorTip = ref('')
  85. const errorTipMessage = ref('')
  86. const purchaseOrderList = ref([])
  87. const scanNumber = ref('')
  88. onBeforeMount(() => {
  89. search()
  90. })
  91. const search = function(keyWord) {
  92. uni.$reqGet("getPurchaseOrderList", {
  93. keyWord: keyWord ?? ''
  94. })
  95. .then(({
  96. code,
  97. data,
  98. msg
  99. }) => {
  100. if (code === 0) {
  101. purchaseOrderList.value = data?.list ?? [];
  102. setInputFocus();
  103. } else {
  104. // #ifdef APP-PLUS
  105. plus.device.beep(2)
  106. // #endif
  107. errorTipMessage.value = msg
  108. errorTip.value.open()
  109. errorState.value = 0
  110. }
  111. })
  112. }
  113. const handleMapass = function() {
  114. // #ifdef APP-PLUS
  115. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  116. mpaasScanModule.mpaasScan({
  117. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  118. 'scanType': ['qrCode', 'barCode'],
  119. // 是否隐藏相册,默认false不隐藏
  120. 'hideAlbum': false
  121. },
  122. (ret) => {
  123. if (ret.resp_code === 1000) {
  124. search(ret.resp_result)
  125. }
  126. })
  127. // #endif
  128. }
  129. // 扫描完成品标签输入框回车事件
  130. const handleKeydown = function(e) {
  131. search(e)
  132. }
  133. const handleNavigateToInfoDetail = function(parent, detail) {
  134. const parentData = JSON.parse(JSON.stringify(parent))
  135. Reflect.deleteProperty(parentData, 'detail');
  136. const params = {
  137. ...parentData,
  138. detail
  139. }
  140. uni.navigateTo({
  141. url: `/pages/workbranch/warehouse/materialRegister/Input/materialInfoDetails?params=${JSON.stringify(params)}`
  142. })
  143. }
  144. const goBack = function() {
  145. uni.$goBack('/pages/workbranch/warehouse/materialRegister/registerType')
  146. }
  147. const setInputFocus = function() {
  148. scanNumber.value = ''
  149. easyinput.value.onBlur()
  150. easyinput.value.onFocus()
  151. }
  152. // 关闭错误信息弹窗
  153. const handleCloseErrorTipsModal = async function() {
  154. errorTip.value.close()
  155. if (errorState.value === 0) {
  156. await setInputFocus()
  157. }
  158. }
  159. // 禁用软键盘
  160. const handleInputFocus = function() {
  161. setTimeout(() => {
  162. uni.hideKeyboard()
  163. }, 100)
  164. }
  165. return {
  166. goBack,
  167. easyinput,
  168. errorTip,
  169. errorTipMessage,
  170. handleInputFocus,
  171. modalForm,
  172. scanNumber,
  173. handleMapass,
  174. handleKeydown,
  175. purchaseOrderList,
  176. handleNavigateToInfoDetail,
  177. handleCloseErrorTipsModal
  178. }
  179. }
  180. })
  181. </script>
  182. <style lang="scss" scoped>
  183. .gui-header-leader-btns {
  184. color: black;
  185. margin-left: 24rpx;
  186. font-size: 24px !important;
  187. }
  188. .list-content {
  189. margin-top: 80px;
  190. min-height: calc(100vh - 80px);
  191. background-color: #edeeee;
  192. }
  193. .input-200 {
  194. width: 200px;
  195. padding-left: 10px;
  196. }
  197. .icon-scan {
  198. font-size: 20px;
  199. text-align: right;
  200. }
  201. .scan {
  202. height: 45px;
  203. width: calc(100% - 48px);
  204. margin: 12px;
  205. padding: 0 12px;
  206. display: flex;
  207. justify-content: space-between;
  208. align-items: center;
  209. border-radius: 6px;
  210. background-color: white;
  211. .scan-card {
  212. width: 100%;
  213. display: grid;
  214. grid-template-rows: 1fr;
  215. grid-template-columns: 7fr 2fr;
  216. align-items: center;
  217. input {
  218. height: 35px;
  219. line-height: 35px;
  220. }
  221. text {
  222. width: 100%;
  223. text-align: right;
  224. }
  225. }
  226. }
  227. span,
  228. text {
  229. font-size: 12px;
  230. }
  231. .collapsed-panel {
  232. // height: calc(100vh - 190px);
  233. // min-height: 230px;
  234. margin: 5px 0;
  235. padding: 0 8px;
  236. overflow-y: scroll;
  237. .panel {
  238. position: relative;
  239. margin: 8px 0;
  240. .top {
  241. font-weight: bold;
  242. border-top-left-radius: 4px;
  243. border-top-right-radius: 4px;
  244. background-color: white;
  245. .panel-row {
  246. line-height: 32px;
  247. padding: 0 12px;
  248. display: flex;
  249. justify-content: space-between;
  250. span:nth-of-type(1) {
  251. min-width: 30%;
  252. }
  253. span:nth-of-type(2) {
  254. min-width: 30%;
  255. padding-right: 8px;
  256. text-align: right;
  257. word-wrap: break-word;
  258. overflow-y: scroll;
  259. }
  260. span {
  261. color: rgba(0, 160, 233, 1);
  262. }
  263. }
  264. }
  265. .content {
  266. position: relative;
  267. overflow-y: scroll;
  268. border-top: 2px dashed rgba(237, 238, 238, 1);
  269. .panel-row {
  270. // height: 32px;
  271. line-height: 32px;
  272. padding: 0 12px;
  273. display: flex;
  274. justify-content: space-between;
  275. background-color: #fbfbfb;
  276. span:nth-of-type(1) {
  277. min-width: 30%;
  278. }
  279. span:nth-of-type(2) {
  280. min-width: 30%;
  281. padding-right: 8px;
  282. text-align: right;
  283. word-wrap: break-word;
  284. overflow-y: scroll;
  285. }
  286. }
  287. .font-icons {
  288. position: absolute;
  289. right: 2px;
  290. top: 50%;
  291. transform: translate(0, -50%);
  292. z-index: 1;
  293. }
  294. }
  295. }
  296. }
  297. </style>