<!--app首页列表--> <template> <div class="app-container" style="background-color: #fff"> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['ops:product:add']" >新增 </el-button > </el-col> <el-col :span="1.5"> <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['ops:product:edit']" >修改 </el-button > </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['ops:product:remove']" >删除 </el-button > </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" ></right-toolbar> </el-row> <el-table :data="productList" @selection-change="handleSelectionChange"> <!-- <el-table-column type="selection" width="55" align="center" />--> <el-table-column label="ID" align="center" prop="subId"/> <el-table-column label="菜单Id" align="center" prop="amenuId"/> <el-table-column label="列表图片" align="center" prop="subImg"> <template slot-scope="scope"> <image-preview :src="scope.row.subImg" :width="100" :height="100"/> </template> </el-table-column> <el-table-column label="描述1" align="center" prop="subTitle"/> <el-table-column label="描述2" align="center" prop="subUrlTitle"/> <el-table-column label="描述3" align="center" prop="remark"/> <el-table-column label="链接" align="center" prop="subUrl"/> <el-table-column label="类型" align="center" prop="subType" /> <el-table-column label="显示顺序" align="center" prop="orderNum" /> <el-table-column label="创建时间" align="center" prop="createTime"/> <!-- <el-table-column prop="status" label="状态" width="100">--> <!-- <template slot-scope="scope">--> <!-- <el-tag :type="scope.row.status === 0 ? '' : 'success'">--> <!-- {{ scope.row.status | switchStatus }}</el-tag--> <!-- >--> <!-- </template>--> <!-- </el-table-column>--> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" > <template slot-scope="scope"> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['ops:product:edit']" >修改 </el-button > <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['ops:product:remove']" >删除 </el-button > </template> </el-table-column> </el-table> <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <!-- 添加或修改产品对话框 --> <el-dialog :title="title" :visible.sync="dialogFormVisible" width="600px"> <el-form :model="form" label-width="98px"> <el-form-item label="菜单Id" prop="amenuId " :rules="[{ required: true }]" > <el-input v-model="form.amenuId" placeholder="请输入菜单Id" clearable disabled @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="图片"> <image-upload v-model="form.subImg"/> </el-form-item> <div style="display: flex; margin-top: 30px"> <div style="height: 35px; line-height: 35px; margin-left: 50px"> <!-- <template>类型: <el-radio v-model="form.status+''" label="1">首页弹窗</el-radio> <el-radio v-model="form.status+''" label="0">通用</el-radio></template> <template>状态: <el-radio v-model="form.status+''" label="1">正常</el-radio> <el-radio v-model="form.status+''" label="0">停用</el-radio> </template> --> </div> </div> <div style="display: flex; margin-top: 30px"> <el-form-item label="显示顺序" prop="orderNum"> <el-input v-model="form.orderNum" placeholder="请输入显示顺序"/> </el-form-item> </div> <el-form-item label="跳转链接" prop="subUrl"> <el-input type="textarea" v-model="form.subUrl" placeholder="请输入跳转链接" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="描述一" prop="subTitle"> <el-input type="textarea" v-model="form.subTitle " placeholder="请输入内容" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="描述二" prop="subUrlTitle"> <el-input type="textarea" v-model="form.subUrlTitle" placeholder="请输入内容" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="描述三" prop="remark"> <el-input type="textarea" v-model="form.remark" placeholder="请输入内容" clearable @keyup.enter.native="handleQuery" /> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button @click="cancel">取 消</el-button> <el-button type="primary" @click="submitForm" >确 定 </el-button > </div> </el-dialog> </div> </template> <script> // import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/ops/product"; import { getxiangqing, getxiangqingone, putxiangqing, delxiangqing, addxiangqing, exportxiangqing } from '@/api/ops/app/shouye.js' import { Toolbar } from '@wangeditor/editor-for-vue' import { getToken } from '@/utils/auth' import { getProductlist, getProductone, putProduct } from '@/api/ops/vip/product' // import { addProduct, getProductlist, getProductone, putProduct } from '@/api/ops/vip/product' // import { Editor, Toolbar } from '@wangeditor/editor-for-vue' export default { name: 'Product', dicts: ['sys_normal_disable'], components: { Toolbar }, data() { return { headers: { Authorization: getToken() }, // urls: this.$urls, editor: null, dialogImageUrl: '', dialogVisible: false, img: '', toolbarConfig: {}, editorConfig: { placeholder: '请输入内容...' }, mode: 'default', // or 'simple' //类型 leixing: '', // 状态 status: '', // 遮罩层 loading: true, // 选中数组 ids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 产品表格数据 productList: [], // 弹出层标题 title: '', // 是否显示弹出层 dialogFormVisible: false, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, userName: null, bankName: null, bankNum: null, openBank: null, phoneNum: null, amenuId: null, status: null }, // 表单参数 form: {}, // 表单校验 rules: {} } }, created() { // console.log(this.$route.query.id) this.queryParams.amenuId = this.$route.query.id this.getList() }, filters: { switchStatus(val) { let res if (val === 0) res = '待支付' if (val === 1) res = '正常' return res } }, beforeDestroy() { const editor = this.editor if (editor == null) return editor.destroy() // 组件销毁时,及时销毁编辑器 }, methods: { onCreated(editor) { this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错 }, /** 查询产品列表 */ /** 查询产品列表 */ getList() { this.loading = true getxiangqing(this.queryParams).then((res) => { console.log(res) this.productList = res.rows this.total = res.total this.loading = false }) }, // 取消按钮 cancel() { this.dialogFormVisible = false }, // 表单重置 reset() { this.form = { pageNum: 1, pageSize: 10, amenuId: this.queryParams.amenuId, userName: null, bankName: null, bankNum: null, openBank: null, phoneNum: null, status: null } this.resetForm('form') }, /** 搜索按钮操作 */ handleQuery() { console.log(204) // this.queryParams.pageNum = 1; // this.getList(); }, /** 重置按钮操作 */ resetQuery() { this.resetForm('queryForm') this.reset() this.queryParams.status = null this.handleQuery() }, // 多选框选中数据 handleSelectionChange(selection) { console.log(216) // this.ids = selection.map(item => item.productId) // this.single = selection.length!==1 // this.multiple = !selection.length }, /** 新增按钮操作 */ handleAdd() { this.reset() this.dialogFormVisible = true this.title = '添加app首页列表管理' }, /** 修改按钮操作 */ handleUpdate(row) { this.reset() getxiangqingone(row.subId).then((res) => { this.form = res.data console.log(this.form) console.log(this.dialogImageUrl) this.dialogFormVisible = true this.title = '修改app首页列表管理' }) }, /** 提交按钮 */ submitForm() { if (this.form.subId != null) { putxiangqing(this.form).then(response => { this.$modal.msgSuccess('修改成功') this.dialogFormVisible = false this.showimg = '' this.getList() }) } else { addxiangqing(this.form).then((response) => { this.$modal.msgSuccess('新增成功') this.dialogFormVisible = false this.getList() }) } }, /** 删除按钮操作 */ handleDelete(row) { // delxiangqing(row.subId).then((res) => { // console.log(res); // }); const productIds = row.subId this.$modal.confirm('是否确认删除产品编号为"' + productIds + '"的数据项?').then(function() { return delxiangqing(productIds) }).then(() => { this.getList() this.$modal.msgSuccess('删除成功') }).catch(() => { }) }, /** 导出按钮操作 */ handleExport() { // exportxiangqing("传参").then((res)=>{ // console.log(res); // }) console.log(422) // this.download('ops/product/export', { // ...this.queryParams // }, `product_${new Date().getTime()}.xlsx`) } } } </script>