123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <div class="tenant">
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :selectConfig="selectConfig"
- highlight-current-row
- @get-list="getList"
- >
- </byTable>
- </div>
- <el-dialog
- title="出库"
- v-if="dialogVisible"
- v-model="dialogVisible"
- width="400"
- v-loading="loadingDialog"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="submit"
- >
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large"
- >确 定</el-button
- >
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { computed, ref } from "vue";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { ElMessage } from "element-plus";
- const { proxy } = getCurrentInstance();
- const warehouseList = ref([]);
- const productType = ref([]);
- const productUnit = ref([]);
- const status = ref([
- {
- label: "待出库",
- value: 0,
- },
- {
- label: "部分出库",
- value: 1,
- },
- {
- label: "出库完成",
- value: 2,
- },
- ]);
- const businessType = ref([
- {
- label: "线边回仓",
- value: 1,
- },
- {
- label: "完工入库",
- value: 2,
- },
- {
- label: "采购到货",
- value: 3,
- },
- {
- label: "退货出库",
- value: 4,
- },
- {
- label: "京东订单",
- value: 5,
- },
- {
- label: "销售订单出库",
- value: 6,
- },
- {
- label: "生产任务出库",
- value: 7,
- },
- {
- label: "销售换货",
- value: 10,
- },
- ]);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- status: "",
- type: 2,
- },
- });
- const loading = ref(false);
- const selectConfig = computed(() => {
- return [
- {
- label: "出库状态",
- prop: "status",
- data: status.value,
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "数据来源",
- prop: "businessType",
- width: 120,
- },
- render(type) {
- return proxy.dictValueLabel(type, businessType.value);
- },
- },
- {
- attrs: {
- label: "单号",
- prop: "businessCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "物品类型",
- prop: "productType",
- width: 120,
- },
- render(type) {
- return proxy.dictValueLabel(type, productType.value);
- },
- },
- {
- attrs: {
- label: "物品编码",
- prop: "productCode",
- width: 140,
- },
- },
- {
- attrs: {
- label: "物品名称",
- prop: "productName",
- "min-width": 200,
- },
- },
- {
- attrs: {
- label: "规格型号",
- prop: "productSpec",
- width: 140,
- },
- },
- {
- attrs: {
- label: "单位",
- prop: "productUnit",
- width: 120,
- },
- render(unit) {
- return proxy.dictValueLabel(unit, productUnit.value);
- },
- },
- {
- attrs: {
- label: "待出库数量",
- prop: "quantity",
- width: 120,
- },
- },
- {
- attrs: {
- label: "出库状态",
- prop: "status",
- width: 140,
- },
- render(type) {
- return proxy.dictValueLabel(type, status.value);
- },
- },
- {
- attrs: {
- label: "操作",
- width: "80",
- align: "center",
- },
- renderHTML(row) {
- return [
- row.status !== 2
- ? {
- attrs: {
- label: "出库",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- clickOperation(row);
- },
- }
- : {},
- ];
- },
- },
- ];
- });
- const getDict = () => {
- proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- if (res.rows && res.rows.length > 0) {
- warehouseList.value = res.rows.map((item) => {
- return {
- label: item.name,
- value: item.id,
- };
- });
- }
- });
- proxy.getDictOne(["product_type", "unit"]).then((res) => {
- productType.value = res["product_type"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- productUnit.value = res["unit"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/stockWaitDetails/page", sourceList.value.pagination)
- .then((res) => {
- sourceList.value.data = res.rows.map((x) => ({
- ...x,
- quantity: (x.quantity - x.receiptQuantity).toFixed(4),
- }));
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getDict();
- getList();
- const dialogVisible = ref(false);
- const loadingDialog = ref(false);
- const submit = ref(null);
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formData = reactive({
- data: {},
- });
- const formConfig = computed(() => {
- return [
- {
- label: "待出库信息",
- },
- {
- type: "select",
- prop: "businessType",
- label: "数据来源",
- disabled: true,
- data: businessType.value,
- },
- {
- type: "input",
- prop: "businessCode",
- label: "单号",
- itemType: "text",
- disabled: true,
- },
- {
- type: "input",
- prop: "productName",
- label: "物品名称",
- itemType: "text",
- disabled: true,
- },
- {
- type: "input",
- prop: "quantity",
- label: "待出库数量",
- itemType: "text",
- disabled: true,
- },
- {
- label: "本次出库",
- },
- {
- type: "select",
- prop: "warehouseId",
- label: "仓库名称",
- required: true,
- data: warehouseList.value,
- },
- {
- type: "number",
- prop: "warehousingQuantity",
- label: "出库数量",
- precision: 0,
- min: 1,
- controls: false,
- },
- ];
- });
- const rules = ref({
- warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
- warehousingQuantity: [
- { required: true, message: "请输入出库数量", trigger: "blur" },
- ],
- });
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- loadingDialog.value = true;
- if (formData.data.warehousingQuantity > Number(formData.data.quantity)) {
- return ElMessage({
- message: "出库数量不可大于待出库数量",
- type: "info",
- });
- }
- proxy
- .post("/stockWait/add", {
- id: formData.data.id,
- warehouseId: formData.data.warehouseId,
- quantity: formData.data.warehousingQuantity,
- })
- .then(
- () => {
- ElMessage({
- message: "提交成功",
- type: "success",
- });
- dialogVisible.value = false;
- getList();
- },
- (err) => {
- console.log(err);
- loadingDialog.value = false;
- }
- );
- });
- };
- const clickOperation = (row) => {
- formData.data = row;
- loadingDialog.value = false;
- dialogVisible.value = true;
- };
- </script>
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|