| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <style>
- .form-body {
- padding: 20px 50% 20px 20px;
- background-color: #fff;
- margin-bottom: 20px;
- min-width: 1000px;
- }
- .form-button {
- margin: 0;
- }
- .form-button .el-form-item__content {
- margin-left: 0 !important;
- }
- .button-item {
- padding: 9px 25px;
- }
- .el-dialog__body {
- padding: 0 !important;
- }
- .el-dialog__header {
- padding: 0 !important;
- }
- </style>
- <?php
- use yii\helpers\Url;
- $diyRoute = Url::to(['goods-template/diy']);
- ?>
- <div id="app" v-cloak>
- <el-card class="box-card" v-loading="listLoading" shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header" class="clearfix">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item><span style="color: #409EFF;cursor: pointer" @click="$navigate({r:'mall/goods-template/index'})">广告模板</span></el-breadcrumb-item>
- <el-breadcrumb-item>模板编辑</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="form-body">
- <el-form :model="form" label-width="150px" :rules="FormRules" ref="form">
- <el-form-item label="模板名称" prop="name" required>
- <el-input size="small" v-model="form.name" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="模板编号" prop="id">
- <el-input size="small" v-model="form.id" disabled autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="是否为默认模版" prop="is_default">
- <el-radio-group v-model="form.is_default">
- <el-radio :label="0">否</el-radio>
- <el-radio :label="1">是</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-radio-group v-model="form.status">
- <el-radio :label="1">启用</el-radio>
- <el-radio :label="0">禁用</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="商品样式" prop="template_id">
- <el-button plain style="width: 200px;" @click="styleDialog">{{form.template_id > 0 ? "编辑样式": "设置样式"}}</el-button>
- </el-form-item>
- </el-form>
- </div>
- <el-button class="button-item" type="primary" :loading="btnLoading" @click="onSubmit">提交</el-button>
- </el-card>
- <el-dialog width="100%" height="100%" :fullscreen="isfullscreen" :visible.sync="visibleDialog" :close-on-click-modal="false">
- <div style="width:100%;height: 100%;position: absolute;">
- <iframe style="width: 100%;height: 100%;" :src="diyRoute">
- </iframe>
- </div>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- form: {
- id: 0,
- name: '',
- is_default: 0,
- status: 1,
- template_id: 0,
- },
- listLoading: false,
- btnLoading: false,
- FormRules: {},
- visibleDialog: false,
- isfullscreen: true,
- diyRoute: "<?= $diyRoute; ?>",
- };
- },
- methods: {
- styleDialog() {
- this.visibleDialog = true;
- },
- onSubmit() {
- this.$refs.form.validate((valid) => {
- if (valid) {
- if (!this.form.template_id || this.form.template_id <= 0) {
- this.$message.error('请设置商品样式后再提交');
- return;
- }
- this.btnLoading = true;
- console.log(this.form);
- request({
- params: {
- r: 'mall/goods-template/edit',
- },
- data: this.form,
- method: 'post'
- }).then(e => {
- if (e.data.code === 0) {
- navigateTo({
- r: 'mall/goods-template/index'
- });
- } else {
- this.$message.error(e.data.msg);
- }
- this.btnLoading = false;
- }).catch(e => {
- this.btnLoading = false;
- });
- }
- });
- },
- getDetail() {
- this.listLoading = true;
- request({
- params: {
- r: 'mall/goods-template/edit',
- id: getQuery('id'),
- },
- }).then(e => {
- if (e.data.code == 0) {
- this.form = Object.assign(this.form, e.data.data);
- if (this.form.template_id > 0) {
- this.diyRoute = this.diyRoute + '&id=' + this.form.template_id;
- }
- } else {
- this.$message.error(e.data.msg);
- }
- this.listLoading = false;
- }).catch(e => {
- this.listLoading = false;
- });
- },
- },
- mounted() {
- this.getDetail();
- window.addEventListener('message', (ev) => {
- let data = ev.data;
- if (Object.prototype.toString.call(data) === '[object String]') {
- data = JSON.parse(data);
- if (Object.keys(data).length !== 0) {
- if (this.form.template_id <= 0) this.form.template_id = data.id;
- }
- }
- this.visibleDialog = false;
- }, false);
- }
- })
- </script>
|