index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="page">
  3. <view class="form-content">
  4. <uni-forms :model-value="form" labelWidth="140px">
  5. <!-- 选择工厂 -->
  6. <uni-forms-item class="form-item" :label="$t('inventory.search.factory')">
  7. <uni-data-picker
  8. v-model="form.factoryId"
  9. :popup-title="$t('inventory.search.factory')"
  10. :localdata="factoryList"
  11. :map="{ text: 'factoryName', value: 'id' }"
  12. />
  13. </uni-forms-item>
  14. <!-- 选择库存地点 -->
  15. <!-- <uni-forms-item class="form-item" :label="$t('inventory.search.storageLocation')">
  16. <uni-data-picker
  17. v-model="form.storageLocationId"
  18. :popup-title="$t('inventory.search.storageLocation')"
  19. :localdata="storageLocationList"
  20. :map="{ text: 'storageLocationName', value: 'id' }"
  21. />
  22. </uni-forms-item> -->
  23. <!-- 选择成本中心 -->
  24. <uni-forms-item class="form-item" :label="$t('inventory.search.costCenter')">
  25. <uni-data-picker
  26. v-model="form.costCenterId"
  27. :popup-title="$t('inventory.search.costCenter')"
  28. :localdata="costCenterList"
  29. :map="{ text: 'costCenterName', value: 'id' }"
  30. />
  31. </uni-forms-item>
  32. <!-- 填写物料编码 -->
  33. <uni-forms-item class="form-item" :label="$t('inventory.search.materialCode')">
  34. <uni-easyinput
  35. v-model="form.materialCode"
  36. :inputBorder="false"
  37. :clearable="false"
  38. :styles="{ disableColor: '#fff' }"
  39. :placeholder="$t('inventory.search.materialCodeHint')"
  40. style="text-align: right"
  41. />
  42. </uni-forms-item>
  43. <!-- 填写物料名称 -->
  44. <uni-forms-item class="form-item" :label="$t('inventory.search.materialName')">
  45. <uni-easyinput
  46. v-model="form.materialName"
  47. :inputBorder="false"
  48. :clearable="false"
  49. :styles="{ disableColor: '#fff' }"
  50. :placeholder="$t('inventory.search.materialNameHint')"
  51. style="text-align: right"
  52. />
  53. </uni-forms-item>
  54. <!-- 选择入库时间 -->
  55. <uni-forms-item class="form-item" :label="$t('inventory.search.storageTime')">
  56. <uni-datetime-picker
  57. v-model="form.storageTime"
  58. type="daterange"
  59. return-type="string"
  60. start-placeholder=" "
  61. :end-placeholder="$t('inventory.search.storageTimeHint')"
  62. :range-separator="!form.storageTime || !form.storageTime[0] ? '' : '-'"
  63. :class="!form.storageTime || !form.storageTime[0] ? 'time-hint-color' : undefined"
  64. :border="false"
  65. />
  66. </uni-forms-item>
  67. </uni-forms>
  68. <uni-row style="margin-top: 20px" :gutter="20">
  69. <uni-col :span="12">
  70. <button type="primary" @click="reset">{{ $t('inventory.search.reset') }}</button>
  71. </uni-col>
  72. <uni-col :span="12">
  73. <button type="primary" @click="confirm">{{ $t('operation.search') }}</button>
  74. </uni-col>
  75. </uni-row>
  76. </view>
  77. </view>
  78. </template>
  79. <script setup>
  80. import { reactive, ref } from 'vue'
  81. import { onLoad } from '@dcloudio/uni-app'
  82. import { filteredSimpleSapOrgList } from "@/api"
  83. const form = reactive({
  84. factoryId: undefined,
  85. costCenterId: undefined,
  86. materialCode: undefined,
  87. materialName: undefined,
  88. storageTime: undefined,
  89. })
  90. const reset = () => {
  91. form.factoryId = undefined
  92. form.costCenterId = undefined
  93. form.materialCode = undefined
  94. form.materialName = undefined
  95. form.storageTime = undefined
  96. uni.$emit('search', {})
  97. uni.navigateBack()
  98. }
  99. const confirm = async () => {
  100. if (form.storageTime && form.storageTime[0]) {
  101. form.storageTime[0] = form.storageTime[0] + ' 00:00:00'
  102. form.storageTime[1] = form.storageTime[1] + ' 23:59:59'
  103. }
  104. // 去掉空值和无用的参数
  105. const params = {}
  106. Object.entries(form).forEach(([key, value]) => {
  107. if (Number.isNaN(Number.parseInt(key)) && value) {
  108. params[key] = value
  109. }
  110. })
  111. uni.$emit('search', params)
  112. uni.navigateBack()
  113. }
  114. const factoryList = ref([])
  115. const costCenterList = ref([])
  116. onLoad(async (options) => {
  117. // 获取工厂、成本中心列表
  118. const getFactoryList = filteredSimpleSapOrgList(1)
  119. const getCostCenterList = filteredSimpleSapOrgList(2)
  120. factoryList.value = (await getFactoryList).data
  121. costCenterList.value = (await getCostCenterList).data
  122. if (options.params) {
  123. Object.assign(form, JSON.parse(options.params))
  124. }
  125. })
  126. </script>
  127. <style lang="scss" scoped>
  128. @import "@/style/choose-device.scss";
  129. @import "@/style/work-order-detail.scss";
  130. .segmented-control {
  131. margin-bottom: 15px;
  132. }
  133. .button-group {
  134. margin-top: 15px;
  135. display: flex;
  136. justify-content: space-around;
  137. }
  138. .button {
  139. display: flex;
  140. align-items: center;
  141. height: 35px;
  142. line-height: 35px;
  143. margin-left: 10px;
  144. }
  145. :deep(.input-value-border) {
  146. border: 0 !important;
  147. }
  148. :deep(.input-value) {
  149. text-align: end;
  150. }
  151. :deep(.selected-list) {
  152. display: block;
  153. }
  154. :deep(.selected-area) {
  155. display: block;
  156. margin-right: 5px;
  157. }
  158. :deep(.uni-data-pickerview .selected-area) {
  159. display: none;
  160. }
  161. :deep(.tab-c) {
  162. margin-left: 30px;
  163. margin-right: 30px;
  164. border-top: 1px dashed #CACCCF;
  165. .item {
  166. border-bottom: 1px dashed #CACCCF;
  167. }
  168. }
  169. :deep(.uni-forms-item) {
  170. margin-bottom: 0;
  171. }
  172. .popup-content {
  173. height: 500px;
  174. }
  175. .device-item {
  176. height: 35px;
  177. line-height: 35px;
  178. padding: 0 30px;
  179. font-size: 13px;
  180. color: #333333;
  181. border-bottom: 1px #CACCCF;
  182. }
  183. .selected {
  184. color: #004098;
  185. }
  186. .divider {
  187. height: 0.5px;
  188. margin: 0 28px;
  189. background-color: #CACCCF;
  190. }
  191. .time-hint-color {
  192. color: #999999;
  193. }
  194. .submit-btn {
  195. width: 100%;
  196. height: 48px;
  197. border-radius: 0;
  198. }
  199. </style>