zuozhengqing
2024-04-11 763762fca04a6dcf391f75e9541fe7287f6b0ed1
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
<template>
  <div class="add_wordshop">
    <el-dialog :title="editConfig.dialogTitle + '生丝定价标准'" :visible.sync="editConfig.visible" width="30%"
      :before-close="handleClose">
      <el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules"
        ref="ruleForm">
        <el-form-item prop="market" label="庄口" style="width: 100%;">
          <el-select :disabled="this.editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.market" value-key="ID"
            placeholder="请选择庄口">
            <el-option v-for="item in shanguchiList" :key="item.name" :label="item.name" :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="rawSilkGrade" label="生丝等级" style="width: 100%;">
          <el-select :disabled="this.editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.rawSilkGrade"
            placeholder="请选择生丝等级">
            <el-option v-for="item in classList" :key="item" :label="item" :value="item">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="payStandard" label="薪酬标准" style="width: 100%;">
          <!-- <el-input-number
            v-model="form.workshopNumber"
            placeholder="请输入组别"
            :controls="false"
            style="width: 100%; margin-right: 5px;text-align:left;"
          ></el-input-number> -->
          <el-input :disabled="this.editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.payStandard" :rows="4"
            style="resize: none !important;" placeholder="请输入薪酬标准">
          </el-input>
        </el-form-item>
        <el-form-item label="单位" style="width: 100%;">
          <el-input :disabled="this.editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.unit" :rows="4"
            style="resize: none !important;" placeholder="请输入组别">
          </el-input>
        </el-form-item>
        <el-form-item label="备注" style="width: 100%;">
          <el-input :disabled="this.editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.notes" type="textarea"
            :rows="4" style="resize: none !important;" placeholder="">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editConfig.visible = false">取 消</el-button>
        <el-button type="primary" @click="commitForm('ruleForm')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { getDict, getRankStandardGrade, savePriceStandard } from "@/api/systemSetting/silkPriceStandard"
export default {
  props: {
    editDiaConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          dialogTitle: "添加",
          isReadonly: true,
          infomitton: {
          },
        }
      }
    }
  },
  data() {
    return {
      editConfig: this.editDiaConfig,
      form: {
        workshopNumber: null,
        groupNumber: null,
        startCarNumber: null,
        endCarNumber: null,
        carFlag: null,
        notes: null
      },
      shanguchiList: [],
      carFlagList: [
        { id: 1, name: "左半车" },
        { id: 2, name: "右半车" },
        { id: 3, name: "全车结束" },
      ],
      classList: [],
      rules: {
        market: [
          { required: true, message: '请选择庄口', trigger: 'change' }
        ],
        rawSilkGrade: [
          { required: true, message: '请选择生丝等级', trigger: 'change' }
        ],
        payStandard: [
          { required: true, message: '请输入薪酬标准', trigger: 'change' },
          {pattern: /^[0-9.]*$/, message: '薪酬标准需为数字', trigger: 'blur'}
        ]
      },
    };
  },
  computed: {
  },
  created() {
    this.getDictData()
    this.getRankStandardGrade()
  },
  mounted() {
 
  },
  watch: {
 
  },
  methods: {
    handleClose(done) {
      done();
    },
    async getDictData() {
      await getDict({ dictType: 0 }).then((res) => {
        if (res && res.code === 200) {
          this.shanguchiList = res.data
        }
      })
    },
    setParams() {
      let params = {
        marketId: this.editConfig.infomitton.market.ID,
        marketName: this.editConfig.infomitton.market.name,
        unit: this.editConfig.infomitton.unit,
        payStandard: Number(this.editConfig.infomitton.payStandard),
        rawSilkGrade: this.editConfig.infomitton.rawSilkGrade,
        notes: this.editConfig.infomitton.notes,
        // id:Number(this.editConfig.infomitton.workshopId),
      }
      return params
    },
    async commitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let params = this.setParams()
          console.log(this.editConfig.infomitton.market,params,"看那")
          if (this.editConfig.dialogTitle === "新增") {
            savePriceStandard(params).then((res) => {
              if (res && res.code === 200) {
                this.editConfig.visible = false
                this.$message({
                  message: "保存成功!",
                  type: "success",
                });
                this.$parent.getData()
              }
            })
          } else if (this.editConfig.dialogTitle === "修改") {
            this.editConfig.infomitton.workshopNumber = this.editConfig.infomitton.workshopNumber + ""
            savePriceStandard({...params,id:this.editConfig.infomitton.ID}).then((res) => {
              if (res && res.code === 200) {
                this.editConfig.visible = false
                this.$message({
                  message: "保存成功!",
                  type: "success",
                });
                this.$parent.getData()
              }
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    async getRankStandardGrade() {
      await getRankStandardGrade().then((res) => {
        if (res && res.data) {
          this.classList = res.data
        }
      })
    }
  },
  components: {
 
  },
};
</script>
 
<style scoped lang="scss">
::v-deep .el-form-item__content {
  width: 70% !important;
}
 
::v-deep {
  .el-form {
    .el-input__inner {
      text-align: left;
    }
  }
 
  .el-select {
    width: 100%;
  }
}
</style>