huminmin
20 小时以前 eb956d7f1a0d174c0d55fccebfa4872d2abfbe94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <template>
    <div>
      <el-dialog
          v-model="isShow"
          title="新增产品"
          width="1200"
          @close="closeModal"
      >
        <div class="table_list">
          <el-table :data="tableData"
                    border
                    @selection-change="handleChangeSelection">
            <el-table-column align="center"
                             type="selection"
                             width="55" />
            <el-table-column align="center"
                             label="序号"
                             type="index"
                             width="60" />
            <el-table-column label="产品大类"
                             prop="productCategory" />
            <el-table-column label="规格型号"
                             prop="specificationModel" />
            <el-table-column label="单位"
                             prop="unit"
                             width="70" />
            <el-table-column label="数量"
                             prop="quantity"
                             width="70" />
            <el-table-column label="库存预警数量"
                             prop="warnNum"
                             width="120"
                             show-overflow-tooltip />
            <el-table-column label="税率(%)"
                             prop="taxRate"
                             width="80" />
            <el-table-column label="含税单价(元)"
                             prop="taxInclusiveUnitPrice"
                             :formatter="formattedNumber"
                             width="150" />
            <el-table-column label="含税总价(元)"
                             prop="taxInclusiveTotalPrice"
                             :formatter="formattedNumber"
                             width="150" />
            <el-table-column label="不含税总价(元)"
                             prop="taxExclusiveTotalPrice"
                             :formatter="formattedNumber"
                             width="150" />
            <el-table-column label="是否质检"
                             prop="isChecked"
                             width="150">
              <template #default="scope">
                <el-tag :type="scope.row.isChecked ? 'success' : 'info'">
                  {{ scope.row.isChecked ? '是' : '否' }}
                </el-tag>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper"
                      :page="page.current" :limit="page.size" @pagination="paginationChange" />
        </div>
 
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" :disabled="selectedRows.length === 0" @click="handleSubmit">确认</el-button>
            <el-button @click="closeModal">取消</el-button>
          </div>
        </template>
      </el-dialog>
    </div>
  </template>
</template>
 
<script setup>
import {computed, reactive, ref} from "vue";
import {productList} from "@/api/procurementManagement/procurementLedger.js";
import {ElMessage} from "element-plus";
 
const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
  },
 
  purchaseLedgerId: {
    type: Number,
    required: true,
  }
});
 
const emit = defineEmits(['update:visible', 'completed']);
 
const isShow = computed({
  get() {
    return props.visible;
  },
  set(val) {
    emit('update:visible', val);
  },
});
 
const tableData = ref([])
const selectedRows = ref([])
const tableLoading = ref(false)
const page = reactive({
  current: 1,
  size: 100,
})
const total = ref(0)
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
 
const paginationChange = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList()
}
 
const handleChangeSelection = (val) => {
  selectedRows.value = val;
}
 
const fetchData = () => {
  tableLoading.value = true;
  productList({salesLedgerId: props.purchaseLedgerId, type: 2}).then((res) => {
    tableData.value = res.data;
  }).finally(() => {
    tableLoading.value = false;
  })
}
 
const handleSubmit = () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning("请选择一条产品");
    return;
  }
 
  emit('completed', selectedRows.value);
}
 
const closeModal = () => {
  isShow.value = false;
};
 
onMounted(() => {
  fetchData()
})
 
</script>