add.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <el-card class="box-card">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" ref="submit">
  4. <template #checkBomList>
  5. <div style="width: 100%">
  6. <div style="margin-bottom: 10px">
  7. <el-upload :show-file-list="false" action="##" :http-request="uploadServerLog">
  8. <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">导入</el-button>
  9. </el-upload>
  10. </div>
  11. <el-table :data="formData.data.checkBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  12. <el-table-column label="品号" prop="bomSpecCode" width="140" />
  13. <el-table-column label="品名" prop="bomSpecName" min-width="240" />
  14. <el-table-column label="事业部" prop="departmentName" width="120" />
  15. <el-table-column label="仓库" prop="warehouseName" width="120" />
  16. <el-table-column label="剩余库存" prop="surplusStock" width="120" />
  17. <el-table-column label="盘点数量" prop="checkQuantity" width="120" />
  18. <el-table-column label="结存单价" prop="balanceUnitPrice" width="100" />
  19. <el-table-column label="状态" width="80">
  20. <template #default="{ row }">
  21. <span v-if="row.status == 1">正常</span>
  22. <span v-else-if="row.status == 2" style="color: #f59a23">盘盈</span>
  23. <span v-else-if="row.status == 3" style="color: #d9001b">盘亏</span>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. </template>
  29. </byForm>
  30. <div style="text-align: center; margin: 10px">
  31. <el-button @click="clickCancel()" size="large">取 消</el-button>
  32. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
  33. </div>
  34. </el-card>
  35. </template>
  36. <script setup>
  37. import byForm from "/src/components/byForm/index";
  38. import { ElMessage } from "element-plus";
  39. import { useRouter } from "vue-router";
  40. import useTagsViewStore from "/src/store/modules/tagsView";
  41. const { proxy } = getCurrentInstance();
  42. const router = useRouter();
  43. const formOption = reactive({
  44. inline: true,
  45. labelWidth: "100px",
  46. itemWidth: 100,
  47. rules: [],
  48. labelPosition: "right",
  49. });
  50. const formData = reactive({
  51. data: {
  52. checkBomList: [],
  53. },
  54. });
  55. const formConfig = computed(() => {
  56. return [
  57. {
  58. type: "title",
  59. title: "盘点信息",
  60. label: "",
  61. },
  62. {
  63. type: "slot",
  64. slotName: "checkBomList",
  65. label: "",
  66. },
  67. ];
  68. });
  69. const clickCancel = () => {
  70. const useTagsStore = useTagsViewStore();
  71. useTagsStore.delVisitedView(router.currentRoute.value);
  72. router.replace({
  73. path: "/production/warehouse/warehouse-check",
  74. });
  75. };
  76. const uploadServerLog = (params) => {
  77. let file = params.file;
  78. let data = new FormData();
  79. data.append("file", file);
  80. proxy.postUploadFile("/check/excelImport", data).then((res) => {
  81. ElMessage({ message: "导入成功", type: "success" });
  82. formData.data = res.data;
  83. });
  84. };
  85. const submitForm = () => {
  86. if (formData.data.checkBomList && formData.data.checkBomList.length > 0) {
  87. proxy.post("/check/add", formData.data).then(() => {
  88. ElMessage({ message: "提交成功", type: "success" });
  89. clickCancel();
  90. });
  91. } else {
  92. return ElMessage("请导入盘点数据");
  93. }
  94. };
  95. </script>
  96. <style lang="scss" scoped></style>