addManualInbound.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div v-loading="loading">
  3. <div class="form-box">
  4. <el-form
  5. label-position="top"
  6. :model="form"
  7. ref="form"
  8. :rules="formRules"
  9. label-width="100px"
  10. >
  11. <el-row>
  12. <el-col :span="6">
  13. <el-form-item label="仓库名称" prop="warehouseId">
  14. <el-select
  15. v-model="form.warehouseId"
  16. placeholder="请选择"
  17. style="width: 100%"
  18. @change="handleChangeWarehouse"
  19. >
  20. <el-option
  21. v-for="item in warehouseSelectList"
  22. :key="item.id"
  23. :label="item.name"
  24. :value="item.id"
  25. >
  26. <span style="float: left">{{
  27. `${item.name}(${dictDataEcho(
  28. item.type,
  29. warehouseTypeList
  30. )})`
  31. }}</span>
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. </el-row>
  37. <el-row>
  38. <el-col :span="10">
  39. <el-form-item label="备注" prop="remarks">
  40. <el-input
  41. placeholder="请输入"
  42. v-model="form.remarks"
  43. type="textarea"
  44. :rows="4"
  45. >
  46. </el-input>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <div style="margin-bottom: 20px">
  51. <labelTitle content="入库明细"></labelTitle>
  52. </div>
  53. <el-form-item label-width="0px">
  54. <el-button type="primary" size="mini" @click="handleAddProduct">
  55. 添加明细</el-button
  56. >
  57. </el-form-item>
  58. <el-form-item>
  59. <el-table :data="form.changeProductList">
  60. <el-table-column label="物品编码" prop="productCode">
  61. </el-table-column>
  62. <el-table-column label="物品名称" prop="productName">
  63. </el-table-column>
  64. <el-table-column label="规格" prop="specs"> </el-table-column>
  65. <el-table-column label="本次入库" prop="quantity">
  66. <template slot-scope="scope">
  67. <el-form-item
  68. :prop="'changeProductList.' + scope.$index + '.quantity'"
  69. :rules="formRules.quantity"
  70. :inline-message="true"
  71. label-width="0"
  72. >
  73. <el-input
  74. v-model="scope.row.quantity"
  75. placeholder="请输入"
  76. size="mini"
  77. >
  78. </el-input>
  79. </el-form-item>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="操作" width="100" align="left">
  83. <template slot-scope="scope">
  84. <el-button type="text" @click="deleteRow(scope.$index)">
  85. 删除
  86. </el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </el-form-item>
  91. </el-form>
  92. </div>
  93. <div style="text-align: center; margin-top: 15px">
  94. <el-button size="small" @click="handleCancel">取消 </el-button>
  95. <el-button type="primary" size="small" @click="handleSubmit">
  96. 确定</el-button
  97. >
  98. </div>
  99. <el-dialog
  100. title="物品选择"
  101. v-if="selectDialog"
  102. :visible.sync="selectDialog"
  103. width="80%"
  104. top="60px"
  105. >
  106. <selectProduct @select="handleSelect"></selectProduct>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. import labelTitle from "@/components/label-title/index.vue";
  112. import selectProduct from "@/components/select-product/index.vue";
  113. export default {
  114. name: "addInbound",
  115. components: { labelTitle, selectProduct },
  116. props: {
  117. form: {
  118. type: Object,
  119. default: () => {},
  120. },
  121. warehouseSelectList: {
  122. type: Array,
  123. default: () => [],
  124. },
  125. warehouseTypeList: {
  126. type: Array,
  127. default: () => [],
  128. },
  129. },
  130. data() {
  131. return {
  132. selectLit: [],
  133. loading: false,
  134. formRules: {
  135. warehouseId: [
  136. {
  137. required: true,
  138. message: "请选择仓库",
  139. trigger: "change",
  140. },
  141. ],
  142. quantity: [
  143. {
  144. required: true,
  145. message: "请输入本次入库数量",
  146. trigger: "blur",
  147. },
  148. ],
  149. },
  150. selectDialog: false,
  151. warehouseName: "",
  152. };
  153. },
  154. created() {},
  155. methods: {
  156. handleSubmit() {
  157. this.$refs.form.validate((valid) => {
  158. if (valid) {
  159. if (this.form.changeProductList.length < 1) {
  160. return this.msgInfo("请添加入库明细!");
  161. }
  162. this.loading = true;
  163. this.form.changeProductList = this.form.changeProductList.map(
  164. (x) => ({
  165. productId: x.productId,
  166. quantity: x.quantity,
  167. })
  168. );
  169. this.$emit("submit");
  170. }
  171. });
  172. },
  173. handleCancel() {
  174. this.$emit("cancel");
  175. },
  176. handleChangeWarehouse(id) {
  177. // const current = this.warehouseSelectList.find((x) => x.id === id);
  178. // if (current) {
  179. // this.warehouseName = current.name;
  180. // }
  181. this.form.changeProductList = [];
  182. },
  183. handleAddProduct() {
  184. if (!this.form.warehouseId) return this.msgInfo("请先选择仓库");
  185. this.selectDialog = true;
  186. },
  187. handleSelect(row) {
  188. const flag = this.form.changeProductList.some(
  189. (x) => x.productId === row.id
  190. );
  191. if (flag) return this.msgInfo("该物品已经选择");
  192. const product = {
  193. productCode: row.code,
  194. productName: row.name,
  195. productId: row.id,
  196. specs: row.specs,
  197. quantity: "",
  198. };
  199. this.form.changeProductList.push(product);
  200. this.msgSuccess("选择成功");
  201. },
  202. deleteRow(index) {
  203. this.form.changeProductList.splice(index, 1);
  204. this.msgSuccess("删除成功");
  205. },
  206. },
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. .form-box {
  211. height: calc(100vh - 280px);
  212. overflow: auto;
  213. box-sizing: border-box;
  214. padding: 10px;
  215. }
  216. ::v-deep {
  217. .el-form-item {
  218. margin-bottom: 3px;
  219. }
  220. .el-form--label-top .el-form-item__label {
  221. padding: 8px 0 0 0;
  222. }
  223. }
  224. </style>