|
@@ -149,7 +149,7 @@
|
|
|
<el-form ref="addForm" :model="addForm" :rules="rules" size="mini" inline>
|
|
|
<el-row>
|
|
|
<el-col :span="22">
|
|
|
- <el-form-item label="数据周期">
|
|
|
+ <el-form-item label="数据周期" prop="date">
|
|
|
<div v-if="addForm.monthOrWeek==='1'">
|
|
|
<el-date-picker
|
|
|
v-model="addForm.date"
|
|
@@ -181,48 +181,85 @@
|
|
|
</el-form>
|
|
|
<el-table :data="addList" class="add-table" border size="mini">
|
|
|
<el-table-column label="物料名称" prop="materialName">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>物料名称</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input v-model="scope.row.materialName" size="mini" placeholder="请输入物料名称"
|
|
|
:disabled="addForm.monthOrWeek==='2'"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="规格" prop="specification">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>规格</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input v-model="scope.row.specification" size="mini" placeholder="请输入物料规格"
|
|
|
:disabled="addForm.monthOrWeek==='2'"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="品牌/货号" prop="articleNo">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>品牌/货号</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input v-model="scope.row.articleNo" size="mini" placeholder="请输入品牌/货号"
|
|
|
:disabled="addForm.monthOrWeek==='2'"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="厂商" prop="factory">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>厂商</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input v-model="scope.row.factory" size="mini" placeholder="请输入厂商"
|
|
|
:disabled="addForm.monthOrWeek==='2'"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="单位" prop="unit" width="120px">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>单位</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input v-model="scope.row.unit" size="mini" placeholder="请输入单位" :disabled="addForm.monthOrWeek==='2'"
|
|
|
- style="width: 100%"/>
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.unit"
|
|
|
+ filterable
|
|
|
+ allow-create
|
|
|
+ default-first-option
|
|
|
+ :disabled="addForm.monthOrWeek==='2'"
|
|
|
+ style="width: 100%">
|
|
|
+ <el-option v-for="item in unitOptions"
|
|
|
+ :key="item"
|
|
|
+ :label="item"
|
|
|
+ :value="item">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <!-- <el-input v-model="scope.row.unit" size="mini" placeholder="请输入单位" :disabled="addForm.monthOrWeek==='2'"-->
|
|
|
+ <!-- style="width: 100%"/>-->
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="价格" prop="price" width="120px">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>价格</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input v-model="scope.row.price" size="mini" placeholder="请输入单价" :disabled="addForm.monthOrWeek==='2'"
|
|
|
style="width: 100%"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="领取量" prop="num" width="100px">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>领取量</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-input-number v-model="scope.row.num" size="mini" controls-position="right" :min="0"
|
|
|
placeholder="请输入领取量" style="width: 100%"/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="物料类型" prop="materialType" width="100px">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span style="color: red">*</span><span>物料类型</span>
|
|
|
+ </template>
|
|
|
<template slot-scope="scope">
|
|
|
<el-select v-model="scope.row.materialType" size="mini" :disabled="addForm.monthOrWeek==='2'"
|
|
|
style="width: 100%">
|
|
@@ -265,6 +302,28 @@
|
|
|
<el-dialog title="修改" :visible.sync="editOpen" @close="dialogClose" width="500px" append-to-body
|
|
|
:close-on-click-modal="false">
|
|
|
<el-form ref="editForm" :model="editForm" :rules="rules" size="mini" label-width="100px">
|
|
|
+ <el-form-item label="数据周期" prop="date">
|
|
|
+ <div v-if="editForm.monthOrWeek==='1'">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="editForm.date"
|
|
|
+ type="month"
|
|
|
+ value-format="yyyy-MM"
|
|
|
+ placeholder="选择月份"
|
|
|
+ :picker-options="getPickerOptions('month')"
|
|
|
+ clearable>
|
|
|
+ </el-date-picker>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="editForm.date"
|
|
|
+ type="week"
|
|
|
+ format="yyyy 第 WW 周"
|
|
|
+ placeholder="选择周"
|
|
|
+ :picker-options="getPickerOptions('week')"
|
|
|
+ clearable>
|
|
|
+ </el-date-picker>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="物料名称" prop="materialName">
|
|
|
<el-input v-model="editForm.materialName" placeholder="请输入物料名称" :disabled="editForm.monthOrWeek==='2'"/>
|
|
|
</el-form-item>
|
|
@@ -372,6 +431,9 @@ export default {
|
|
|
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
+ date: [
|
|
|
+ {required: true, message: "数据周期不能为空", trigger: "change"}
|
|
|
+ ],
|
|
|
materialName: [
|
|
|
{required: true, message: "物料名称不能为空", trigger: "blur"}
|
|
|
],
|
|
@@ -396,7 +458,8 @@ export default {
|
|
|
monthOrWeek: [
|
|
|
{required: true, message: "月/周数据不能为空", trigger: "change"}
|
|
|
]
|
|
|
- }
|
|
|
+ },
|
|
|
+ unitOptions: ['个', '张', '卷', '支']
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -619,11 +682,35 @@ export default {
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
this.editForm = row
|
|
|
+ if (this.editForm.monthOrWeek === '1') {
|
|
|
+ this.$set(this.editForm, 'date', row.recordDate)
|
|
|
+ } else {
|
|
|
+ let split = row.recordDate.split('~');
|
|
|
+ this.$set(this.editForm, 'date', split[0])
|
|
|
+ }
|
|
|
this.editOpen = true
|
|
|
},
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
+ if (this.addList.length === 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let checkKeys = ['materialName', 'specification', 'articleNo', 'factory', 'unit', 'num', 'materialType']
|
|
|
+ let validFlag = true
|
|
|
+ this.addList.forEach(item => {
|
|
|
+ for (let key in item) {
|
|
|
+ if (checkKeys.indexOf(key) > -1) {
|
|
|
+ if (item[key] === null || item[key] === undefined || item[key] === '' || item[key] === 0) {
|
|
|
+ validFlag = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!validFlag) {
|
|
|
+ this.$message.error("必填项不能为空")
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.$refs["addForm"].validate(valid => {
|
|
|
if (valid) {
|
|
|
let data = {
|