inquire.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="inquire">
  3. <view class="orderNumber">
  4. <view class="form">
  5. <uni-forms :modelValue="orderNumber" ref="form">
  6. <uni-forms-item name="number" label="生产单号:">
  7. <uni-easyinput v-model="orderNumber.number" type="text" :disabled='disabledInp'
  8. placeholder="请输入生产单号" />
  9. </uni-forms-item>
  10. <uni-forms-item name="serial" label="物料编号:">
  11. <uni-easyinput v-model="orderNumber.serial" maxlength="6" :disabled='disabledInp' type="number"
  12. placeholder="请输入物料编号" />
  13. </uni-forms-item>
  14. </uni-forms>
  15. <button type="primary" class="button" @click="examine" :disabled='disabledInp'>查询</button>
  16. </view>
  17. </view>
  18. <view class="message">
  19. <view class="form">
  20. <uni-forms :modelValue="formData" ref="form1">
  21. <uni-forms-item name="time" label="推送日期:">
  22. <uni-datetime-picker type="date" :clear-icon="false" v-model="formData.time" />
  23. </uni-forms-item>
  24. <uni-forms-item name="num" label="数量(箱/件):">
  25. <uni-easyinput v-model="formData.num" type="number" placeholder="请输入数量" />
  26. </uni-forms-item>
  27. </uni-forms>
  28. <button type="primary" class="button" :disabled="disabled" @click="pushMessage">推送</button>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. getWO,
  36. pushWO
  37. } from "../../api/inquire.js"
  38. export default {
  39. data() {
  40. return {
  41. orderNumber: {
  42. number: null,
  43. serial: null
  44. },
  45. formData: {
  46. time: null,
  47. num: null,
  48. },
  49. disabled: true,
  50. disabledInp: false,
  51. ReferbillID: null,
  52. ReferbillItemID: null,
  53. bottleNum: null,
  54. rules: {
  55. number: {
  56. rules: [{
  57. required: true,
  58. errorMessage: '请输入生产单号',
  59. }]
  60. },
  61. serial: {
  62. rules: [{
  63. required: true,
  64. errorMessage: '请输入物料编号',
  65. }]
  66. },
  67. time: {
  68. rules: [{
  69. required: true,
  70. errorMessage: '请选择日期',
  71. }]
  72. },
  73. num: {
  74. rules: [{
  75. required: true,
  76. errorMessage: '请输入数量',
  77. }]
  78. },
  79. }
  80. };
  81. },
  82. onReady() {
  83. // 需要在onReady中设置规则
  84. this.$refs.form.setRules(this.rules)
  85. this.$refs.form1.setRules(this.rules)
  86. },
  87. methods: {
  88. // 查
  89. examine() {
  90. this.$refs.form.validate().then(res => {
  91. uni.showLoading({
  92. title: '查询中...'
  93. });
  94. this.orderNumber.number = res.number.replace(/\s+/g, "").toUpperCase()
  95. getWO({
  96. DocNum: this.orderNumber.number,
  97. Material: this.orderNumber.serial,
  98. accessToken: uni.getStorageSync('tokenInfo'),
  99. account: uni.getStorageSync('account')
  100. }).then(res1 => {
  101. uni.hideLoading();
  102. if (res1.data.success == 0) {
  103. uni.showToast({
  104. title: res1.data.message,
  105. icon: 'success',
  106. duration: 2000
  107. })
  108. this.ReferbillID = res1.data.data.ReferbillID
  109. this.ReferbillItemID = res1.data.data.ReferbillItemID
  110. this.bottleNum = res1.data.data.bottleNum
  111. this.disabled = false
  112. this.disabledInp = true
  113. } else {
  114. uni.showToast({
  115. title: res1.data.message,
  116. icon: 'none',
  117. duration: 2000
  118. })
  119. }
  120. }).catch(err1 => {
  121. uni.hideLoading();
  122. })
  123. }).catch(err => {
  124. uni.hideLoading()
  125. console.log('表单错误信息:', err);
  126. })
  127. },
  128. // 推
  129. pushMessage() {
  130. this.$refs.form1.validate().then(res => {
  131. uni.showLoading({
  132. title: '推送中...'
  133. });
  134. pushWO({
  135. boxNum: res.num,
  136. bottleNum: this.bottleNum,
  137. DocNum: this.orderNumber.number,
  138. ReferbillItemID: this.ReferbillItemID,
  139. ReferbillID: this.ReferbillID,
  140. Material: this.orderNumber.serial,
  141. SourceBillDate: res.time.replace(/\-/g, ""),
  142. accessToken: uni.getStorageSync('tokenInfo'),
  143. account: uni.getStorageSync('account')
  144. }).then(res1 => {
  145. if (res1.data.success == 0) {
  146. uni.hideLoading();
  147. uni.showToast({
  148. title: res1.data.message,
  149. icon: 'success',
  150. duration: 2000
  151. })
  152. this.orderNumber = {
  153. number: null,
  154. serial: null
  155. }
  156. this.formData = {
  157. time: null,
  158. num: null,
  159. }
  160. this.disabled = true
  161. this.disabledInp = false
  162. } else {
  163. uni.showToast({
  164. title: res1.data.message,
  165. icon: 'none',
  166. duration: 2000
  167. })
  168. this.disabledInp = false
  169. }
  170. }).catch(err1 => {
  171. uni.hideLoading();
  172. })
  173. }).catch(err => {
  174. uni.hideLoading()
  175. console.log('表单错误信息:', err);
  176. })
  177. },
  178. }
  179. }
  180. </script>
  181. <style lang="scss" lang="scss">
  182. .inquire {
  183. width: 100%;
  184. height: 100%;
  185. display: flex;
  186. flex-direction: column;
  187. .orderNumber {
  188. width: 100%;
  189. height: 40%;
  190. position: relative;
  191. .form {
  192. width: 90%;
  193. position: absolute;
  194. top: 50%;
  195. left: 50%;
  196. transform: translate(-50%, -50%);
  197. .uni-forms ::v-deep {
  198. .uni-forms-item__label {
  199. width: 30% !important;
  200. text-align: right;
  201. }
  202. }
  203. }
  204. }
  205. .message {
  206. flex: 1;
  207. padding-top: 100rpx;
  208. box-sizing: border-box;
  209. .form {
  210. width: 90%;
  211. margin: 0 auto;
  212. .uni-forms ::v-deep {
  213. .uni-forms-item__label {
  214. width: 30% !important;
  215. text-align: right;
  216. }
  217. }
  218. }
  219. }
  220. p {
  221. span {
  222. font-size: 30rpx;
  223. }
  224. }
  225. .orderNumber {
  226. border-bottom: 1px solid #ccc;
  227. }
  228. }
  229. </style>