index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <z-paging ref="paging" bgColor="#F7F7F7" safe-area-inset-bottom paging-class="paging-btm-shadow" scroll-with-animation>
  3. <template #top>
  4. <ut-navbar title="库存损耗登记" :fixed="false" border></ut-navbar>
  5. </template>
  6. <up-form class="p-rtv pd-24" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormRef">
  7. <view class="bg-fff b-radius-16">
  8. <view class="pd-24 up-border-bottom">
  9. <template v-if="info?.stockType === '1'">
  10. <view class="d-flex j-ed a-c mb-16">
  11. <view class="f-s-22 c-#666">{{ info?.instoreBizInfo?.instoreDate }}</view>
  12. </view>
  13. <view class="d-flex flex1 mb-10">
  14. <view class="flex1">
  15. <span class="f-s-34 c-#333 f-w-500 mr-10">{{ info?.materialName }}</span>
  16. <span class="f-s-24 c-#666">{{ selectDictLabel(pt_material_type, info?.materialType) }}</span>
  17. </view>
  18. <view>
  19. <view v-if="info?.examinReport?.length" class="tag-span c-primary bg-#EBF6EE">已检验</view>
  20. <view v-else class="tag-span c-danger bg-#F9ECEA">未检验</view>
  21. </view>
  22. </view>
  23. <view class="pd2-4-0 f-s-28">
  24. <span class="c-#666">入库批号:</span>
  25. <span class="c-#333 f-w-500">{{ info?.batchCode }}</span>
  26. </view>
  27. <view v-if="info?.supplier" class="pd2-4-0 f-s-28">
  28. <span class="c-#666">供应商:</span>
  29. <span class="c-#333 f-w-500">{{ info?.supplier }}</span>
  30. </view>
  31. <view class="pd2-4-0 f-s-28">
  32. <span class="c-#666">入库量:</span>
  33. <span class="c-#333 f-w-500">{{ info?.capacity }}{{ info?.unit }}</span>
  34. </view>
  35. <view class="d-flex">
  36. <view v-if="info?.restAmount" class="pd2-4-0 f-s-28 flex1">
  37. <span class="c-#666">出库量:</span>
  38. <span class="c-#333 f-w-500">{{ info?.inputAmount || '0' }}{{ info?.unit }}</span>
  39. </view>
  40. <view v-if="info?.restAmount" class="pd2-4-0 f-s-28 flex1">
  41. <span class="c-primary">剩余量:</span>
  42. <span class="c-primary f-w-500">{{ info?.restAmount || '0' }}{{ info?.unit }}</span>
  43. </view>
  44. </view>
  45. </template>
  46. <template v-if="info?.stockType === '2'">
  47. <view class="d-flex j-sb a-c li-item-head mb-16">
  48. <view class="li-left-tag" :class="{ [`bg-instore-${info?.instoreType}`]: true }">{{ info?.seedLevel }}{{ selectDictLabel(pt_seed_instore_type, info?.instoreType) }}</view>
  49. <view class="f-s-22 c-#666">{{ info?.updateTime || info?.createTime }}</view>
  50. </view>
  51. <view class="mb-10">
  52. <span class="f-s-34 c-#333 f-w-500 mr-10">{{ info?.variety }}</span>
  53. <span class="f-s-24 c-#666">{{ selectDictLabel(pt_seed_type, info?.seedType) }}</span>
  54. </view>
  55. <view class="pd2-4-0 f-s-28">
  56. <span class="c-#666">入库批号:</span>
  57. <span class="c-#333 f-w-500">{{ info?.batchCode }}</span>
  58. </view>
  59. <view v-if="['A3', 'A4'].includes(info?.fungusCodeType)" class="pd2-4-0 f-s-28">
  60. <span class="c-#666">菌种/菌株编号:</span>
  61. <span class="c-#333 f-w-500">{{ selectDictLabel(pt_fungus_code_type, info?.fungusCodeType) }}/{{ info?.fungusCode }}</span>
  62. </view>
  63. <view class="pd2-4-0 f-s-28">
  64. <span class="c-#666">供应商:</span>
  65. <span class="c-#333 f-w-500">{{ info?.supplier }}</span>
  66. </view>
  67. <view class="pd2-4-0 f-s-28">
  68. <span class="c-#666">入库量:</span>
  69. <span class="c-#333 f-w-500">{{ info?.capacity }}{{ info?.unit }}</span>
  70. </view>
  71. <view class="d-flex">
  72. <view v-if="info?.restAmount" class="pd2-4-0 f-s-28 flex1">
  73. <span class="c-#666">出库量:</span>
  74. <span class="c-#333 f-w-500">{{ info?.inputAmount || '0' }}{{ info?.unit }}</span>
  75. </view>
  76. <view v-if="info?.restAmount" class="pd2-4-0 f-s-28 flex1">
  77. <span class="c-primary">剩余量:</span>
  78. <span class="c-primary f-w-500">{{ info?.restAmount || '0' }}{{ info?.unit }}</span>
  79. </view>
  80. </view>
  81. </template>
  82. <template v-if="info?.stockType === '4'">
  83. <view class="d-flex j-sb a-c li-item-head mb-16">
  84. <view class="li-left-tag" :class="{ [`bg-instore-${info?.instoreType}`]: true }">{{ info?.level }}{{ selectDictLabel(pt_seed_instore_type, info?.instoreType) }}</view>
  85. <view class="f-s-22 c-#666">{{ info?.instoreBizInfo?.instoreDate }}</view>
  86. </view>
  87. <view class="mb-10">
  88. <span class="f-s-34 c-#333 f-w-500 mr-10">{{ info?.variety }}</span>
  89. <span v-if="info?.partName" class="f-s-24 c-#666">{{ info?.partName }}</span>
  90. </view>
  91. <view class="pd2-4-0 f-s-28">
  92. <span class="c-#666">入库批号:</span>
  93. <span class="c-#333 f-w-500">{{ info?.batchCode }}</span>
  94. </view>
  95. <view v-if="info?.supplierId" class="pd2-4-0 f-s-28">
  96. <span class="c-#666">供应商:</span>
  97. <span class="c-#333 f-w-500">{{ info?.supplierInfo?.cusName || '-' }}</span>
  98. </view>
  99. <view v-if="info?.warehouses?.length" class="pd2-4-0 f-s-28">
  100. <span class="c-#666">存放库房:</span>
  101. <span class="c-#333 f-w-500">{{ getStorageRoomNames(info?.warehouses) || '-' }}</span>
  102. </view>
  103. <view class="pd2-4-0 f-s-28">
  104. <span class="c-#666">入库量:</span>
  105. <span class="c-#333 f-w-500">{{ info?.capacity }}{{ info?.unit }}</span>
  106. </view>
  107. <view class="d-flex">
  108. <view v-if="info?.inputAmount" class="pd2-4-0 f-s-28 flex1">
  109. <span class="c-#666">出库量:</span>
  110. <span class="c-#333 f-w-500">{{ info?.inputAmount || '0' }}{{ info?.unit }}</span>
  111. </view>
  112. <view v-if="info?.restAmount" class="pd2-4-0 f-s-28 flex1">
  113. <span class="c-primary">剩余量:</span>
  114. <span class="c-primary f-w-500">{{ info?.restAmount || '0' }}{{ info?.unit }}</span>
  115. </view>
  116. </view>
  117. </template>
  118. </view>
  119. <view class="pd3-10-24-24">
  120. <!-- 损耗登记日期 -->
  121. <!-- 损耗数量 -->
  122. <!-- 备注 -->
  123. <view class="h-1" id="scrapDatepppp"></view>
  124. <ut-datetime-picker v-model="form.scrapDate" :maxDate="new Date()" mode="date">
  125. <up-form-item borderBottom label="损耗登记日期" required prop="scrapDate">
  126. <up-input v-model="form.scrapDate" readonly placeholder="请选择损耗登记日期" border="none" clearable></up-input>
  127. <template #right>
  128. <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
  129. </template>
  130. </up-form-item>
  131. </ut-datetime-picker>
  132. <view class="h-1" id="scrapAmountpppp"></view>
  133. <up-form-item borderBottom label="损耗数量" required prop="scrapAmount">
  134. <up-input v-model="form.scrapAmount" type="number" placeholder="请输入损耗数量" border="none" clearable></up-input>
  135. <template #right>
  136. <view class="c-#333 f-s-28">{{ info?.unit }}</view>
  137. </template>
  138. </up-form-item>
  139. <view class="h-1" id="remarkpppp"></view>
  140. <up-form-item borderBottom label="备注" prop="remark">
  141. <up-textarea v-model="form.remark" placeholder="损耗原因等" autoHeight></up-textarea>
  142. </up-form-item>
  143. </view>
  144. <!-- <view class="h-1" id="contactTelpppp"></view>
  145. <up-form-item borderBottom label="联系电话" prop="contactTel">
  146. <up-input v-model="form.contactTel" placeholder="请输入联系电话" border="none" clearable></up-input>
  147. </up-form-item> -->
  148. </view>
  149. </up-form>
  150. <template #bottom>
  151. <view class="pd-20 d-flex">
  152. <up-button @click="navigateBackOrHome()" class="mr-30" style="color: #333" color="#F2F2F2">取消</up-button>
  153. <up-button @click="submit" type="primary">确认登记</up-button>
  154. </view>
  155. </template>
  156. </z-paging>
  157. </template>
  158. <script setup lang="ts">
  159. import { getStorageRoomNames } from '@/utils/common';
  160. import { useClientRequest } from '@/utils/request';
  161. import { parseTime, selectDictListClass } from '@/utils/ruoyi';
  162. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  163. const { pt_material_type, pt_seed_instore_type, pt_seed_type, pt_fungus_code_type } = toRefs<any>(proxy?.useDict('pt_material_type', 'pt_seed_instore_type', 'pt_seed_type', 'pt_fungus_code_type'));
  164. const upFormRef = ref();
  165. const paging = ref();
  166. const form = ref({
  167. scrapDate: parseTime(new Date(), '{y}-{m}-{d}'),
  168. scrapAmount: '',
  169. remark: '',
  170. });
  171. const info = ref<any>(null);
  172. const rules = reactive({
  173. scrapDate: [{ required: true, message: '请选择损耗登记日期' }],
  174. scrapAmount: [
  175. { required: true, message: '请输入损耗数量' },
  176. {
  177. validator: (rule: any, value: any) => {
  178. if (value === undefined || value === null || value === '') return true;
  179. const amount = Number(value);
  180. if (Number.isNaN(amount)) return false;
  181. return amount > 0;
  182. },
  183. message: '损耗数量需为大于0的数字',
  184. trigger: ['blur', 'change'],
  185. },
  186. {
  187. validator: (rule: any, value: any) => {
  188. if (value === undefined || value === null || value === '') return true;
  189. const amount = Number(value);
  190. if (Number.isNaN(amount)) return true;
  191. const max = Number(info.value?.restAmount ?? 0);
  192. if (!max) return true;
  193. return amount <= max;
  194. },
  195. message: '损耗数量不能超过剩余量',
  196. trigger: ['blur', 'change'],
  197. },
  198. ],
  199. });
  200. const submit = async () => {
  201. try {
  202. await upFormRef.value?.validate();
  203. } catch (error: any) {
  204. const firstErrorField = error && error[0].prop + 'pppp';
  205. paging.value?.scrollIntoViewById(firstErrorField, 30, true);
  206. return;
  207. }
  208. try {
  209. await uni.showLoading({ title: '保存中...', mask: true });
  210. const payload: any = { ...form.value, storageType: info.value?.stockType, targetId: info.value?.id, scrapUnit: info.value?.unit };
  211. const res = await useClientRequest.post('/plt-api/app/storage/scrap', payload);
  212. uni.hideLoading();
  213. if (res && res.code === 200) {
  214. uni.showToast({ title: '登记成功', icon: 'success' });
  215. uni.$emit('storage-registered');
  216. setTimeout(() => uni.navigateBack(), 300);
  217. }
  218. } catch (e) {
  219. uni.hideLoading();
  220. }
  221. };
  222. onLoad((options: any) => {
  223. const instance: any = getCurrentInstance()?.proxy;
  224. const eventChannel = instance?.getOpenerEventChannel();
  225. eventChannel.on('storage-data', (data: any) => {
  226. console.log(data);
  227. info.value = data;
  228. });
  229. });
  230. </script>
  231. <style lang="scss" scoped>
  232. .startline-title {
  233. font-size: 32rpx;
  234. font-weight: 600;
  235. color: #333;
  236. }
  237. .base-bottom-wrap {
  238. background-color: #fff;
  239. }
  240. .tag-span {
  241. padding: 4rpx 12rpx;
  242. font-size: 20rpx;
  243. border-radius: 18rpx;
  244. }
  245. .li-item-head {
  246. margin-left: -24rpx;
  247. margin-top: -24rpx;
  248. }
  249. .li-left-tag {
  250. padding: 6rpx 16rpx;
  251. color: #fff;
  252. border-radius: 0 0 16rpx 0;
  253. font-size: 20rpx;
  254. font-weight: 500;
  255. }
  256. </style>