| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <div id="app" v-cloak>
- <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div class="form_box">
- <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="150px">
- <el-card shadow="never">
- <div slot="header">
- <div>
- <span>基础配置</span>
- </div>
- </div>
- <div>
- <el-row>
- <el-col :span="16">
- <el-form-item label="是否开启" >
- <el-switch v-model="ruleForm.is_enable" :active-value="1" :inactive-value="0"></el-switch>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="弹窗图片" prop="cover">
- <el-col :span="12">
- <com-attachment v-model="ruleForm.picture" :multiple="false" :max="1">
- <el-tooltip class="item" effect="dark" content="建议尺寸:900 * 600" placement="top">
- <el-button size="mini">选择图片</el-button>
- </el-tooltip>
- </com-attachment>
- <div class="customize-share-title" v-if="ruleForm.picture" >
- <image mode="aspectFill" width='120px' :src="ruleForm.picture ? ruleForm.picture : ''"></image>
- <el-button v-if="ruleForm.picture" class="del-btn" size="mini" type="danger" icon="el-icon-close" circle @click="ruleForm.picture = ''"></el-button>
- </div>
- </el-col>
- </el-form-item>
- </div>
- </el-card>
- </el-form>
- <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="store('ruleForm')" size="small">保存</el-button>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- loading: false,
- btnLoading: false,
- ruleForm: {
- is_enable: 0,
- picture: '',
- },
- rules: {
- }
- }
- },
- mounted: function() {
- this.loadData();
- },
- methods: {
- loadData() {
- this.loading = true;
- request({
- params: {
- r: 'purchase/setting/index',
- },
- method: 'get'
- }).then(e => {
- this.loading = false;
- if (e.data.code == 0) {
- Object.assign(this.ruleForm, e.data.data);
- }
- }).catch(e => {
- this.loading = false;
- this.$message.error(e);
- })
- },
- store(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.btnLoading = true;
- request({
- params: {
- r: 'purchase/setting/index',
- },
- method: 'post',
- data: {
- basic: this.ruleForm,
- }
- }).then(e => {
- this.btnLoading = false;
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.$message.error(e);
- this.btnLoading = false;
- })
- } else {
- this.btnLoading = false;
- console.log('error submit!!');
- return false;
- }
- });
- },
- }
- });
- </script>
|