addGood.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="goods-page">
  3. <u-navbar
  4. height="40px"
  5. title="新增录入"
  6. bgColor="rgba(2, 86, 255, 1)"
  7. autoBack
  8. placeholder
  9. titleStyle="color:#fff"
  10. leftIconColor="#fff"
  11. >
  12. <view class="u-nav-slot depot-label" slot="right">
  13. <view class="name" style="color: #fff">{{ curDepotName }}</view>
  14. </view>
  15. </u-navbar>
  16. <view class="container_main">
  17. <u--form
  18. labelPosition="left"
  19. :model="form"
  20. :rules="rules"
  21. labelWidth="90"
  22. >
  23. <u-form-item
  24. label="货物条码"
  25. prop="barCode"
  26. borderBottom
  27. customStyle="padding: 30rpx 0"
  28. >
  29. <u-input v-model="form.barCode" border="none" placeholder="请输入">
  30. <u-image
  31. slot="suffix"
  32. src="@/static/image/scan-icon-2.png"
  33. width="40rpx"
  34. height="40rpx"
  35. @click="scanCode"
  36. ></u-image>
  37. </u-input>
  38. </u-form-item>
  39. <u-form-item
  40. label="货物名称"
  41. prop="materialName"
  42. borderBottom
  43. customStyle="padding: 30rpx 0"
  44. >
  45. <u-input
  46. v-model="form.materialName"
  47. border="none"
  48. placeholder="请输入"
  49. ></u-input>
  50. </u-form-item>
  51. <u-form-item
  52. label="规格"
  53. prop="materialStandard"
  54. borderBottom
  55. customStyle="padding: 30rpx 0"
  56. >
  57. <u-input
  58. v-model="form.materialStandard"
  59. border="none"
  60. placeholder="请输入"
  61. ></u-input>
  62. </u-form-item>
  63. <u-form-item
  64. label="生产日期"
  65. prop="productionDate"
  66. borderBottom
  67. customStyle="padding: 30rpx 0"
  68. >
  69. <view
  70. :class="['date-val', { grey: !form.productionDate }]"
  71. @click="showDatePicker = true"
  72. >{{ form.productionDate ? form.productionDate : "请输入" }}</view
  73. >
  74. </u-form-item>
  75. <u-form-item
  76. label="上传图片"
  77. prop="img"
  78. borderBottom
  79. customStyle="padding: 30rpx 0"
  80. >
  81. <u-upload
  82. :fileList="fileList"
  83. @afterRead="afterRead"
  84. @delete="deletePic"
  85. name="file"
  86. width="120rpx"
  87. height="120rpx"
  88. :maxCount="2"
  89. >
  90. <u-image
  91. src="@/static/image/upload-img.png"
  92. width="120rpx"
  93. height="120rpx"
  94. ></u-image>
  95. </u-upload>
  96. </u-form-item>
  97. <u-form-item
  98. label="库位"
  99. prop="position"
  100. borderBottom
  101. customStyle="padding: 30rpx 0"
  102. >
  103. <u-input
  104. v-model="form.position"
  105. border="none"
  106. placeholder="请输入"
  107. ></u-input>
  108. </u-form-item>
  109. </u--form>
  110. </view>
  111. <u-datetime-picker
  112. :show="showDatePicker"
  113. @cancel="showDatePicker = false"
  114. @confirm="confirmDate"
  115. v-model="dateVal"
  116. mode="date"
  117. ></u-datetime-picker>
  118. <!-- 新增录入-->
  119. <view class="footer">
  120. <u-button class="add-btn" type="primary" plain @click="save">
  121. 保存
  122. </u-button>
  123. </view>
  124. </view>
  125. </template>
  126. <script>
  127. import { mapGetters } from "vuex";
  128. export default {
  129. data() {
  130. return {
  131. form: {
  132. materialName: "",
  133. barCode: "",
  134. productionDate: "",
  135. unit: "",
  136. },
  137. rules: {},
  138. showDatePicker: false,
  139. dateVal: "",
  140. fileList: [],
  141. };
  142. },
  143. computed: {
  144. ...mapGetters(["depotInfo"]),
  145. curDepotId() {
  146. return this.depotInfo ? this.depotInfo.id : "";
  147. },
  148. curDepotName() {
  149. return this.depotInfo ? this.depotInfo.depotName : "";
  150. },
  151. },
  152. onHide() {
  153. uni.$off("scanFinish");
  154. },
  155. onShow() {
  156. uni.$on("scanFinish", (data) => {
  157. this.form.barCode = data;
  158. });
  159. },
  160. methods: {
  161. scanCode() {
  162. this.$scan.scanCode();
  163. },
  164. confirmDate(e) {
  165. console.log("confirmDate====", e);
  166. const { value } = e;
  167. this.form.productionDate = this.$u.date(value, "yyyy-mm-dd");
  168. console.log("form====", this.form);
  169. this.showDatePicker = false;
  170. },
  171. deletePic(e) {
  172. console.log("deletePic====", e);
  173. this.fileList.splice(e.index, 1);
  174. },
  175. afterRead(e) {
  176. console.log("afterRead====", e);
  177. const { file } = e;
  178. this.fileList.push(file);
  179. },
  180. save() {},
  181. },
  182. };
  183. </script>
  184. <style lang="scss" scoped>
  185. .goods-page {
  186. min-height: 100vh;
  187. background-color: #f0f6fb;
  188. .container_main {
  189. margin: 24rpx;
  190. background-color: #fff;
  191. border-radius: 16rpx;
  192. padding: 24rpx;
  193. }
  194. }
  195. .footer {
  196. position: fixed;
  197. bottom: 0;
  198. left: 0;
  199. right: 0;
  200. height: 144rpx;
  201. background-color: #fff;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. .add-btn {
  206. width: 700rpx;
  207. height: 88rpx;
  208. border-radius: 16rpx;
  209. font-size: 36rpx;
  210. font-weight: bold;
  211. color: #fff;
  212. background-color: #0256ff;
  213. line-height: 88rpx;
  214. text-align: center;
  215. }
  216. }
  217. .date-val {
  218. width: 100%;
  219. font-size: 28rpx;
  220. }
  221. .grey {
  222. color: #999;
  223. }
  224. </style>