|
@@ -3,18 +3,30 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="formMain">
|
|
|
<el-col :span="24" class="one">
|
|
|
- <el-button type="primary" plain icon="el-icon-back" size="mini" @click="toBack">返回</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-back"
|
|
|
+ size="mini"
|
|
|
+ @click="toBack"
|
|
|
+ >返回</el-button
|
|
|
+ >
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="two">
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item label="申请年度" prop="apply_year">
|
|
|
- <el-input v-model="form.apply_year" placeholder="请输入申请年度" />
|
|
|
- </el-form-item>
|
|
|
- <excel-view v-if="!excelLoading" ref="excelView" v-model="form.excel" :read="true" :view="viewStyle" />
|
|
|
+ <excel-view
|
|
|
+ v-if="!excelLoading"
|
|
|
+ ref="excelView"
|
|
|
+ v-model="form.excel"
|
|
|
+ :read="true"
|
|
|
+ :view="viewStyle"
|
|
|
+ />
|
|
|
<el-col v-if="!view" :span="24" class="btn">
|
|
|
- <el-button type="primary" @click="onSubmit('form')">提交保存</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit('form')"
|
|
|
+ >提交保存</el-button
|
|
|
+ >
|
|
|
<el-button type="warning" @click="onDraft()">保存草稿</el-button>
|
|
|
- <el-button @click="onReset('form')">重置信息</el-button>
|
|
|
+ <!-- <el-button @click="onReset('form')">重置信息</el-button> -->
|
|
|
</el-col>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
@@ -24,116 +36,122 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import excelView from '@/components/free/excel-view.vue'
|
|
|
-import { mapState, mapGetters, createNamespacedHelpers } from 'vuex'
|
|
|
-const { mapActions: merits_apply } = createNamespacedHelpers('merits_apply')
|
|
|
-const { mapActions: template } = createNamespacedHelpers('template')
|
|
|
+import excelView from "@/components/free/excel-view.vue";
|
|
|
+import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
|
|
|
+const { mapActions: merits_apply } = createNamespacedHelpers("merits_apply");
|
|
|
+const { mapActions: template } = createNamespacedHelpers("template");
|
|
|
export default {
|
|
|
- name: 'FormFrame',
|
|
|
+ name: "FormFrame",
|
|
|
components: { excelView },
|
|
|
props: {
|
|
|
id: { type: String },
|
|
|
- view: { type: Boolean, default: false }
|
|
|
+ view: { type: Boolean, default: false },
|
|
|
},
|
|
|
- data: function() {
|
|
|
+ data: function () {
|
|
|
return {
|
|
|
- form: { excel: {}},
|
|
|
+ form: { excel: {} },
|
|
|
viewStyle: {
|
|
|
height: () => document.documentElement.clientHeight - 250,
|
|
|
- width: () => 800
|
|
|
+ width: () => 800,
|
|
|
},
|
|
|
rules: {
|
|
|
- apply_year: [
|
|
|
- { required: true, message: '请输入申请年度', trigger: 'blur' }
|
|
|
- ]
|
|
|
+ // apply_year: [
|
|
|
+ // { required: true, message: '请输入申请年度', trigger: 'blur' }
|
|
|
+ // ]
|
|
|
},
|
|
|
excel: {},
|
|
|
- excelLoading: true
|
|
|
- }
|
|
|
+ excelLoading: true,
|
|
|
+ };
|
|
|
},
|
|
|
async created() {
|
|
|
- await this.getTemplate()
|
|
|
+ await this.getTemplate();
|
|
|
if (this.id) {
|
|
|
- this.searchInfo(this.id)
|
|
|
- } else { this.init() }
|
|
|
+ await this.searchInfo(this.id);
|
|
|
+ } else {
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
- ...merits_apply(['fetch', 'create', 'update']),
|
|
|
- ...template(['query']),
|
|
|
+ ...merits_apply(["fetch", "create", "update"]),
|
|
|
+ ...template(["query"]),
|
|
|
async init() {
|
|
|
- this.$set(this, `form`, { user_id: this.user_id, user_name: this.name, excel: this.excel })
|
|
|
- this.excelLoading = false
|
|
|
+ this.$set(this, `form`, {
|
|
|
+ user_id: this.user_id,
|
|
|
+ user_name: this.name,
|
|
|
+ excel: this.excel,
|
|
|
+ });
|
|
|
+ this.excelLoading = false;
|
|
|
},
|
|
|
async getTemplate() {
|
|
|
- if (this.id) return
|
|
|
- const res = await this.query()
|
|
|
+ if (this.id) return;
|
|
|
+ const res = await this.query();
|
|
|
if (this.$checkRes(res)) {
|
|
|
- const template = res.data.find(f => f.is_use)
|
|
|
+ const template = res.data.find((f) => f.is_use);
|
|
|
if (template) {
|
|
|
- const { excel = {}} = template
|
|
|
- this.$set(this, 'excel', excel)
|
|
|
+ const { excel = {} } = template;
|
|
|
+ this.$set(this, "excel", excel);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
// 返回
|
|
|
toBack() {
|
|
|
- this.$emit('toBack')
|
|
|
+ this.$emit("toBack");
|
|
|
},
|
|
|
// 提交保存
|
|
|
onSubmit(formName) {
|
|
|
- this.$refs[formName].validate(async(valid) => {
|
|
|
+ this.$refs[formName].validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- const data = this.form
|
|
|
- data.status = '1'
|
|
|
- let res
|
|
|
- if (data.id) res = await this.update(data)
|
|
|
- else res = await this.create(data)
|
|
|
+ const data = this.form;
|
|
|
+ data.status = "1";
|
|
|
+ let res;
|
|
|
+ if (data.id) res = await this.update(data);
|
|
|
+ else res = await this.create(data);
|
|
|
if (res.code === 200) {
|
|
|
- this.$message({ type: `success`, message: res.msg })
|
|
|
- this.toBack()
|
|
|
+ this.$message({ type: `success`, message: res.msg });
|
|
|
+ this.toBack();
|
|
|
} else {
|
|
|
- this.$message({ type: `error`, message: res.msg })
|
|
|
+ this.$message({ type: `error`, message: res.msg });
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('error submit!!')
|
|
|
- return false
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 保存草稿
|
|
|
async onDraft() {
|
|
|
- const data = this.form
|
|
|
- let res
|
|
|
- if (data.id) res = await this.update(data)
|
|
|
- else res = await this.create(data)
|
|
|
+ const data = this.form;
|
|
|
+ let res;
|
|
|
+ if (data.id) res = await this.update(data);
|
|
|
+ else res = await this.create(data);
|
|
|
if (res.code === 200) {
|
|
|
- this.$message({ type: `success`, message: res.msg })
|
|
|
- this.toBack()
|
|
|
+ this.$message({ type: `success`, message: res.msg });
|
|
|
+ this.toBack();
|
|
|
} else {
|
|
|
- this.$message({ type: `error`, message: res.msg })
|
|
|
+ this.$message({ type: `error`, message: res.msg });
|
|
|
}
|
|
|
},
|
|
|
// 查看详情
|
|
|
async searchInfo(id) {
|
|
|
- const res = await this.fetch(id)
|
|
|
+ const res = await this.fetch(id);
|
|
|
if (res.code === 200) {
|
|
|
- this.$set(this, `form`, res.data)
|
|
|
- this.excelLoading = false
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ this.excelLoading = false;
|
|
|
} else {
|
|
|
- this.$message({ type: `error`, message: res.msg })
|
|
|
+ this.$message({ type: `error`, message: res.msg });
|
|
|
}
|
|
|
},
|
|
|
// 重置信息
|
|
|
onReset(formName) {
|
|
|
- this.$refs[formName].resetFields()
|
|
|
- }
|
|
|
+ this.$refs[formName].resetFields();
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(['user_id', 'name'])
|
|
|
+ ...mapGetters(["user_id", "name"]),
|
|
|
},
|
|
|
metaInfo() {
|
|
|
- return { title: this.$route.meta.title }
|
|
|
- }
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
// watch: {
|
|
|
// id: {
|
|
|
// deep: true,
|
|
@@ -143,7 +161,7 @@ export default {
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|