123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <el-dialog
- v-loading="loading"
- :title="title"
- :center="true"
- align="left"
- top="18vh"
- width="500px"
- :close-on-click-modal="false"
- :visible.sync="showModelThis"
- element-loading-text="拼命加载中"
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- @close="showModelThis = false"
- >
- <el-card style="margin: -20px 0 0 0">
- <el-row :gutter="10">
- <el-col :span="24">
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :size="'small'"
- :rules="rulesThis"
- label-width="80px"
- class="demo-ruleForm"
- >
- <el-form-item label="起订量" prop="min_num">
- <el-input
- placeholder="起订量"
- v-model="ruleForm.min_num"
- type="number"
- :min="0"
- :max="9999999999"
- :step="0"
- />
- </el-form-item>
- <el-form-item label="成本合计" prop="nake_fee">
- <el-input
- placeholder="成本合计"
- v-model="ruleForm.nake_fee"
- type="number"
- :min="0"
- :max="9999999999.99"
- :step="2"
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="工艺费" prop="cost_fee">
- <el-input
- placeholder="工艺费"
- v-model="ruleForm.cost_fee"
- type="number"
- :min="0"
- :max="9999999999.99"
- :step="2"
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="其中运费" prop="delivery_fee">
- <el-input
- placeholder="其中运费"
- v-model="ruleForm.delivery_fee"
- type="number"
- :min="0"
- :max="9999999999.99"
- :step="2"
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </el-form>
- </el-col>
- <el-col :span="24" style="text-align: right">
- <el-button :size="'small'" type="primary" @click="submitForm"
- >保 存
- </el-button>
- <el-button @click="showModelThis = false" :size="'small'">{{
- "取 消"
- }}</el-button>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </template>
- <script>
- import resToken from "@/mixins/resToken";
- export default {
- name: "brand",
- props: ["showModel", "index", "sitem"],
- mixins: [resToken],
- data() {
- return {
- loading: false,
- title: "",
- showModelThis: this.showModel,
- ruleForm: {},
- rulesThis: this.rules,
- rules: {
- min_num: [
- { required: true, message: "起订量应为合法数字", trigger: "blur" },
- ],
- cost_fee: [
- { required: true, message: "工艺费应为合法数字", trigger: "blur" },
- ],
- nake_fee: [
- { required: true, message: "成本合计应为合法数字", trigger: "blur" },
- ],
- delivery_fee: [
- { required: true, message: "其中运费应为合法数字", trigger: "blur" },
- ],
- },
- };
- },
- watch: {
- showModel: function (val) {
- this.showModelThis = val;
- if (val) {
- this.initForm();
- }
- },
- showModelThis(val) {
- if (!val) {
- this.$emit("cancel");
- }
- },
- },
- methods: {
- async initForm() {
- this.loading = true;
- await this.resetFormData();
- console.log(this.index);
- if (this.index + "" === "-1") {
- this.title = "添加成本阶梯";
- } else {
- this.title = "修改成本阶梯";
- }
- await this.resetForm();
- this.loading = false;
- },
- async resetForm() {
-
- await this.$nextTick(async () => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- await this.resetFormData();
- }
- });
- },
- async resetFormData() {
- const { id, min_num, cost_fee, nake_fee, delivery_fee } = this.sitem;
- this.ruleForm = {
- id: id || "",
- index: this.index,
- min_num: min_num || "",
- cost_fee: cost_fee || "",
- nake_fee: nake_fee || "",
- delivery_fee: delivery_fee || "",
- };
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.showModelThis = false;
-
- this.$emit("refresh", this.ruleForm);
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .brand {
- }
- </style>
|