gaoluyang
3 天以前 35d6ace96aac27cb6c81bc361503378f6acbd24f
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="search-form">
      <el-form-item label="供应商名称">
        <el-input
            v-model="queryParams.supplierName"
            placeholder="请输入"
            clearable
            :style="{ width: '100%' }"
        />
      </el-form-item>
      <el-form-item label="煤种">
        <el-input
            v-model="queryParams.coal"
            placeholder="请输入"
            clearable
            :style="{ width: '100%' }"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
        <el-button @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-card>
      <!-- 标签页 -->
      <el-tabs
          v-model="activeTab"
          class="info-tabs"
          @tab-click="handleTabClick"
      >
        <el-tab-pane
            v-for="tab in tabs"
            :key="tab.name"
            :label="tab.label"
            :name="tab.name"
        />
      </el-tabs>
      <!-- 操作按钮区 -->
      <el-space>
        <el-button type="danger" :icon="Delete">删除</el-button>
        <el-button type="info" plain :icon="Download">导出</el-button>
        <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows">合并</el-button>
      </el-space>
      <div>
        <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" type="index" width="60" align="center" />
          <el-table-column prop="supplierName" label="供货商名称" width="180" sortable/>
          <el-table-column prop="coal" label="煤种" sortable/>
          <el-table-column prop="unit" label="单位" width="70"/>
          <el-table-column prop="inventoryQuantity" label="库存数量" sortable min-width="110"/>
          <el-table-column prop="priceIncludingTax" label="单价(含税)" sortable width="130"/>
          <el-table-column prop="totalPriceIncludingTax" label="总价(含税)" width="130" />
          <el-table-column prop="costPerUnit" label="成本单价" />
          <el-table-column label="煤质" align="center" v-if="activeTab=== 'officialInventory'" width="600">
            <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/>
          </el-table-column>
          <el-table-column prop="registrant" label="登记人" width="180"/>
          <el-table-column prop="registrationTime" label="登记日期" width="180"/>
          <el-table-column fixed="right" label="操作" min-width="60" align="center" v-if="activeTab !== 'officialInventory'">
            <template #default="scope">
              <el-button link type="primary" size="small" @click="reviewDia(scope.row)">审核</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
            v-if="total>0"
            :page-num="pageNum"
            :page-size="pageSize"
            :total="total"
            @pagination="handleQuery"
            :layout="'total, prev, pager, next, jumper'"
        />
      </div>
    </el-card>
    <!-- 审核待入库弹框 -->
    <el-dialog title="审核入库" v-model="reviewVisible" width="1000px">
      <el-form :model="form" :rules="rules" ref="formRef" label-width="180px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="供货商名称" prop="supplierName">
              <el-input v-model="form.supplierName" placeholder="请输入供货商名称" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="煤种" prop="coal">
              <el-input v-model="form.coal" placeholder="请输入煤种" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入单位" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存数量" prop="inventoryQuantity">
              <el-input v-model="form.inventoryQuantity" placeholder="请输入库存数量" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单价(含税)" prop="priceIncludingTax">
              <el-input v-model="form.priceIncludingTax" placeholder="请输入单价(含税)" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总价(含税)" prop="totalPriceIncludingTax">
              <el-input v-model="form.totalPriceIncludingTax" placeholder="请输入总价(含税)" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="成本单价" prop="costPerUnit">
              <el-input v-model="form.costPerUnit" placeholder="请输入成本单价" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="煤质方案" prop="qualityPlan">
              <el-select v-model="form.qualityPlan" placeholder="请选择" @change="coalFieldListOption" clearable>
                <el-option
                    v-for="dict in qualityPlanOption"
                    :key="dict.id"
                    :label="dict.plan"
                    :value="dict.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12" v-for="item in filteredList" :key="item.id">
            <el-form-item :label="item.fieldName">
              <el-input v-model="form[item.fields]" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitReviewForm">确 定</el-button>
          <el-button @click="cancelReview">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 合并数据弹框 -->
    <el-dialog title="合并库存" v-model="mergeVisible" width="800px">
      <el-form :model="form" :rules="rules" ref="userRef" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="供货商名称" prop="supplierName">
              <el-input v-model="form.supplierName" placeholder="请输入手机号码" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="煤种" prop="coal">
              <el-input v-model="form.coal" placeholder="请输入姓名" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单价(含税)" prop="priceIncludingTax">
              <el-input v-model="form.priceIncludingTax" placeholder="请输入手机号码" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总价(含税)" prop="totalPriceIncludingTax">
              <el-input v-model="form.totalPriceIncludingTax" placeholder="请输入手机号码" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="成本单价" prop="costPerUnit">
              <el-input v-model="form.costPerUnit" placeholder="请输入姓名" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="煤质" prop="userName">
              <el-input v-model="form.userName" placeholder="请输入手机号码" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup>
import {onMounted, ref} from "vue";
import {Delete, Download, Refresh} from "@element-plus/icons-vue";
import Pagination from "@/components/Pagination/index.vue";
import {
  addOrEditCoalValue,
  coalFieldList,
  coalPlanList, officialInventoryList,
  pendingInventoryList
} from "@/api/warehouseManagement/index.js";
 
const { proxy } = getCurrentInstance()
 
const tableData = ref([])
const selectedRows = ref([])
const columns = ref([])
const qualityPlanOption = ref([])
const filteredList = ref([])
const tableLoading = ref(false);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
// 审核弹框
const reviewVisible = ref(false);
// 合并弹框
const mergeVisible = ref(false)
const data = reactive({
  form: {
    supplierName: '',
    coal: '',
    unit: '',
    inventoryQuantity: '',
    priceIncludingTax: '',
    totalPriceIncludingTax: '',
    costPerUnit: '',
    qualityPlan: '',
    planId: '',
  },
  rules: {
    supplierName: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
    coal: [{ required: true, message: "请输入煤种", trigger: "blur" }],
    unit: [{ required: true, message: "请输入单位", trigger: "blur" }],
    qualityPlan: [{ required: true, message: "请选择", trigger: "change" }],
  }
})
 
const { form, rules } = toRefs(data)
// 当前标签
const activeTab = ref("pendingInbound");
const tabName = ref("pendingInbound");
// 标签页数据
const tabs = reactive([
  { name: "pendingInbound", label: "待入库" },
  { name: "officialInventory", label: "正式库存" },
]);
// 查询参数
const queryParams = reactive({
  supplierName: "",
  coal: "",
})
const columnTitle = ref([])
onMounted(() => {
  handleTabClick({ props: { name: "supplier" } });
});
// 标签页点击
const handleTabClick = (tab) => {
  tabName.value = tab.props.name;
  tableData.value = [];
  getList();
};
// 点击查询
const handleQuery = () => {
  pageNum.value = 1
  pageSize.value = 10
  getList()
}
const getList = () => {
  tableLoading.value = true;
  // 赋值煤质表头展示字段
  columnTitle.value = [
    {prop: 'value1', label: '百分比1'},
    {prop: 'value2', label: '百分比2'},
    {prop: 'value3', label: '百分比3'},
  ]
  if (tabName.value === "pendingInbound") {
    pendingInventoryList({ ...queryParams }).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      total.value = res.data.total;
    })
  } else {
    officialInventoryList({ ...queryParams }).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      total.value = res.data.total;
    })
  }
};
// 重置查询
const resetQuery = () => {
  Object.keys(queryParams).forEach((key) => {
    if (key !== "pageNum" && key !== "pageSize") {
      queryParams[key] = "";
    }
  });
  handleQuery();
};
// 表格选择数据
const selectionChange = (rows) => {
  selectedRows.value = rows
}
// 打开审核弹框
const reviewDia = (row) => {
  reviewVisible.value = true
  form.value = {...row}
  form.value.planId = form.value.id
  coalPlanListOptions()
}
// 查询煤质方案下拉框
const coalPlanListOptions = () => {
  coalPlanList().then(res => {
    qualityPlanOption.value = res.data
  })
}
// 查询煤质方案字段
const coalFieldListOption = (id) => {
  coalFieldList({id: id}).then(res => {
    filteredList.value = res.data
    if (!id) {
      filteredList.value = []
    }
  })
}
// 合并库存数据方法
const mergeRows = () => {
  if (selectedRows.value.length < 2) {
    proxy.$modal.msgWarning('请至少选择两条数据')
    return
  }
  mergeVisible.value = true
}
// 提交合并表单
const submitForm = () => {
 
}
// 关闭合并表单
const cancel = () => {
  mergeVisible.value = false
}
// 提交审核表单
const submitReviewForm = () => {
  proxy.$refs.formRef.validate((valid) => {
    if (valid) {
      delete form.value.registrationTime
      delete form.value.createTime
      delete form.value.updateTime
      delete form.value.id
      form.value.fieldValue = filteredList.value.map(item => ({
        [item.fields]: form.value[item.fields]
      }))
      addOrEditCoalValue(form.value).then(() => {
        cancelReview()
        proxy.$modal.msgSuccess('提交成功')
        handleQuery()
      })
    }
  })
}
// 关闭审核弹框
const cancelReview = () => {
  proxy.$refs.formRef.resetFields()
  reviewVisible.value = false
}
</script>
 
<style scoped>
:deep(.el-table) {
  margin: 20px 0;
}
</style>