index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  5. <template #basicInformation>
  6. <div style="width: 100%">
  7. <el-row>
  8. <el-col :span="12">
  9. <el-form-item label="事业部" prop="departmentId" style="width: 100%; margin-bottom: 18px">
  10. <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable style="width: 100%">
  11. <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="出库仓库" prop="outWarehouseId" style="width: 100%; margin-bottom: 18px">
  15. <el-select v-model="formData.data.outWarehouseId" placeholder="请选择出库仓库" clearable style="width: 100%">
  16. <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="入库仓库" prop="inWarehouseId" style="width: 100%; margin-bottom: 18px">
  20. <el-select v-model="formData.data.inWarehouseId" placeholder="请选择入库仓库" clearable style="width: 100%">
  21. <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="申请人" prop="applicant" style="width: 100%; margin-bottom: 18px">
  25. <el-input v-model="formData.data.applicant" placeholder="请输入申请人" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="12">
  29. <el-form-item label="备注" prop="remark" style="width: 100%; margin-bottom: 18px">
  30. <el-input v-model="formData.data.remark" :rows="4" type="textarea" placeholder="请输入备注" />
  31. </el-form-item>
  32. </el-col>
  33. </el-row>
  34. </div>
  35. </template>
  36. <template #inOutStorageBomList>
  37. <div style="width: 100%; padding: 0 20px">
  38. <div style="margin-bottom: 10px">
  39. <el-button type="primary" size="small" @click="clickAddBOM()">选择BOM</el-button>
  40. </div>
  41. <el-table :data="formData.data.inOutStorageBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  42. <el-table-column label="品号" prop="code" width="180" />
  43. <el-table-column label="品名" prop="name" min-width="220" />
  44. <el-table-column label="单品尺寸(L*W*H)" align="center" width="300">
  45. <template #default="{ row }">
  46. <span>{{ `${row.length} * ${row.width} * ${row.height}` }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="入库数量" width="180">
  50. <template #default="{ row, $index }">
  51. <el-form-item :prop="'inOutStorageBomList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" style="width: 100%">
  52. <el-input-number
  53. onmousewheel="return false;"
  54. v-model="row.quantity"
  55. placeholder="入库数量"
  56. style="width: 100%"
  57. :controls="false"
  58. :min="0"
  59. :precision="0" />
  60. </el-form-item>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="操作" align="center" fixed="right" width="60">
  64. <template #default="{ $index }">
  65. <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. </div>
  70. </template>
  71. </byForm>
  72. <div style="text-align: center; margin: 10px">
  73. <el-button @click="clickCancel()" size="large">取 消</el-button>
  74. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
  75. </div>
  76. </el-card>
  77. <el-dialog title="选择BOM" v-if="openBOM" v-model="openBOM" width="90%">
  78. <SelectBOM :selectStatus="true" @selectBOM="selectBOM"></SelectBOM>
  79. <template #footer>
  80. <el-button @click="openBOM = false" size="large">关 闭</el-button>
  81. </template>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script setup>
  86. import byForm from "@/components/byForm/index";
  87. import { ElMessage } from "element-plus";
  88. import { useRouter } from "vue-router";
  89. import useTagsViewStore from "@/store/modules/tagsView";
  90. import SelectBOM from "@/views/group/BOM/management/index";
  91. const { proxy } = getCurrentInstance();
  92. const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
  93. const warehouseList = ref([]);
  94. const router = useRouter();
  95. const submit = ref(null);
  96. const formOption = reactive({
  97. inline: true,
  98. labelWidth: "100px",
  99. itemWidth: 100,
  100. rules: [],
  101. labelPosition: "right",
  102. });
  103. const formData = reactive({
  104. data: {
  105. applicant: proxy.useUserStore().user.nickName,
  106. inOutStorageBomList: [],
  107. },
  108. });
  109. const formConfig = computed(() => {
  110. return [
  111. {
  112. type: "title",
  113. title: "入库信息",
  114. label: "",
  115. },
  116. {
  117. type: "slot",
  118. slotName: "basicInformation",
  119. label: "",
  120. },
  121. {
  122. type: "title",
  123. title: "物料信息",
  124. label: "",
  125. },
  126. {
  127. type: "slot",
  128. slotName: "inOutStorageBomList",
  129. label: "",
  130. },
  131. ];
  132. });
  133. const rules = ref({
  134. departmentId: [{ required: true, message: "请选择事业部", trigger: "change" }],
  135. outWarehouseId: [{ required: true, message: "请选择出库仓库", trigger: "change" }],
  136. inWarehouseId: [{ required: true, message: "请选择入库仓库", trigger: "change" }],
  137. applicant: [{ required: true, message: "请输入申请人", trigger: "blur" }],
  138. quantity: [{ required: true, message: "请输入调拨数量", trigger: "blur" }],
  139. });
  140. const getDemandData = () => {
  141. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  142. if (res.rows && res.rows.length > 0) {
  143. departmentList.value = departmentList.value.concat(
  144. res.rows.map((item) => {
  145. return {
  146. dictKey: item.id,
  147. dictValue: item.name,
  148. };
  149. })
  150. );
  151. }
  152. });
  153. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  154. if (res.rows && res.rows.length > 0) {
  155. warehouseList.value = res.rows.map((item) => {
  156. return {
  157. dictKey: item.id,
  158. dictValue: item.name,
  159. };
  160. });
  161. }
  162. });
  163. };
  164. getDemandData();
  165. const openBOM = ref(false);
  166. const clickAddBOM = () => {
  167. openBOM.value = true;
  168. };
  169. const selectBOM = (item) => {
  170. if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
  171. let list = formData.data.inOutStorageBomList.filter((itemFilter) => itemFilter.bomSpecId === item.id);
  172. if (list && list.length > 0) {
  173. return ElMessage("该BOM已添加");
  174. }
  175. }
  176. if (item.id) {
  177. formData.data.inOutStorageBomList.push({
  178. bomSpecId: item.id,
  179. code: item.code,
  180. name: item.name,
  181. length: item.length,
  182. width: item.width,
  183. height: item.height,
  184. quantity: undefined,
  185. });
  186. ElMessage({ message: "选择完成", type: "success" });
  187. }
  188. };
  189. const clickDelete = (index) => {
  190. formData.data.inOutStorageBomList.splice(index, 1);
  191. };
  192. const submitForm = () => {
  193. submit.value.handleSubmit(() => {
  194. if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
  195. proxy.post("/inOutStorage/add", formData.data).then(() => {
  196. ElMessage({
  197. message: "提交成功",
  198. type: "success",
  199. });
  200. clickCancel();
  201. });
  202. } else {
  203. return ElMessage("请添加BOM");
  204. }
  205. });
  206. };
  207. const clickCancel = () => {
  208. const useTagsStore = useTagsViewStore();
  209. useTagsStore.delVisitedView(router.currentRoute.value);
  210. router.replace({
  211. path: "/production/warehouse/warehouse-putInStorage",
  212. });
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. ::v-deep(.el-input-number .el-input__inner) {
  217. text-align: left;
  218. }
  219. :deep(.el-dialog) {
  220. margin-top: 10px !important;
  221. margin-bottom: 10px !important;
  222. }
  223. </style>