<!--产品--> <template> <div class="app-container" style="background-color: #fff"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="118px" > <el-form-item label="产品名称" prop="productName"> <el-input v-model="queryParams.productName" placeholder="请输入产品名称" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="产品类型" prop="productType"> <el-select v-model="queryParams.productType" placeholder="选择产品类型" clearable style="width: 240px" > <el-option v-for="dict in dict.type.product_type" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="状态"> <el-select v-model="queryParams.status" placeholder="请选择状态"> <el-option v-for="dict in dict.type.commen_status0" :label="dict.label" :key="dict.value" :value="dict.value" ></el-option> </el-select> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" >搜索 </el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" >重置 </el-button> </el-form-item> </el-form> <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> <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="productId" /> <el-table-column label="产品名称" align="center" prop="productName" /> <el-table-column label="产品标志" align="center" prop="productKey" /> <el-table-column label="产品图片" align="center" prop="productImg"> <template slot-scope="scope"> <image-preview :src="scope.row.productImg" :width="100" :height="100" /> </template> </el-table-column> <el-table-column prop="productType" align="center" label="产品类型" width="100" > <!-- 0正常1停用 --> <template slot-scope="scope"> <DictTag :options="dict.type.product_type" :value="scope.row.productType" ></DictTag> </template> </el-table-column> <el-table-column label="价格" align="center" prop="price" /> <el-table-column prop="status" label="状态" width="100"> <!-- 0正常1停用 --> <template slot-scope="scope"> <dict-tag :options="dict.type.commen_status0" :value="scope.row.status" ></dict-tag> </template> </el-table-column> <el-table-column label="产品标题" align="center" prop="productTitle" /> <el-table-column label="产品标题1" align="center" prop="updateMan" /> <el-table-column label="产品标题2" align="center" prop="createMan" /> <el-table-column label="产品标题3" align="center" prop="data" /> <el-table-column label="产品标题4" align="center" prop="fontStyle" /> <el-table-column label="产品描述" align="center" prop="productDescribe" :show-overflow-tooltip="true" /> <el-table-column label="资产类型" align="center" prop="buttonStyle"> <template slot-scope="scope"> <DictTag :options="dict.type.sys_wallet_type" :value="scope.row.buttonStyle" ></DictTag> </template> </el-table-column> <!-- <el-table-column label="是否开启" align="center" prop="delFlag">--> <!-- <template slot-scope="scope">--> <!-- {{ scope.row.delFlag | switchdelFlag }}--> <!-- </template>--> <!-- </el-table-column>--> <!-- <el-table-column label="买一送几" align="center" prop="data" />--> <el-table-column label="详情" align="center"> <template slot-scope="scope"> <el-button size="mini" type="text" @click="next(scope.row)" v-hasPermi="['ops:product:edit']" >查看详情 </el-button> </template> </el-table-column> <!-- <el-table-column label="显示顺序" align="center" prop="orderNum" />--> <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="650px"> <el-form ref="form" :model="form" :rules="rules" label-width="118px"> <div style="display: flex"> <el-form-item label="产品名称" prop="productName"> <el-input v-model="form.productName" placeholder="请输入产品名称" /> </el-form-item> <el-form-item label="价格" prop="price"> <el-input v-model="form.price" placeholder="请输入售价" /> </el-form-item> </div> <el-form-item label="产品标志" prop="productKey"> <el-input v-model="form.productKey" placeholder="请输入产品标志" /> </el-form-item> <el-form-item label="产品类型" prop="productType"> <el-select v-model="form.productType" placeholder="选择产品类型" clearable style="width: 240px" > <el-option v-for="dict in dict.type.product_type" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="图片"> <image-upload v-model="form.productImg" /> </el-form-item> <div style="height: 35px; line-height: 35px; margin-left: 50px"> 是否开启 <el-radio v-model="form.delFlag" label="0">关闭</el-radio> <el-radio v-model="form.delFlag" label="1">开启</el-radio> </div> <el-form-item label="资产类型" prop="buttonStyle"> <el-select v-model="form.buttonStyle" placeholder="请选择资产类型" clearable > <el-option v-for="dict in dict.type.sys_wallet_type" :key="dict.value" :label="dict.label" :value="dict.value" ></el-option> </el-select> </el-form-item> <!-- <el-form-item label="买一送几" prop="data">--> <!-- <el-input v-model="form.data" placeholder="请输入买一送几" />--> <!-- </el-form-item>--> <div style="display: flex"> <el-form-item label="产品标题1" prop="updateMan"> <el-input v-model="form.updateMan" placeholder="请输入产品标志" /> </el-form-item> <el-form-item label="产品标题2" prop="createMan"> <el-input v-model="form.createMan" placeholder="请输入产品标志" /> </el-form-item> </div> <div style="display: flex"> <el-form-item label="产品标题3" prop="data"> <el-input v-model="form.data" placeholder="请输入产品标志" /> </el-form-item> <el-form-item label="产品标题4" prop="fontStyle"> <el-input v-model="form.fontStyle" placeholder="请输入产品标志" /> </el-form-item> </div> <div style="display: flex"> <el-form-item label="产品标题" prop="productTitle"> <el-input v-model="form.productTitle" placeholder="请输入产品标志" /> </el-form-item> <el-form-item label="状态" prop="status"> <el-select v-model="form.status" placeholder="请选择状态"> <el-option v-for="dict in dict.type.commen_status0" :label="dict.label" :key="dict.value" :value="dict.value" ></el-option> </el-select> </el-form-item> </div> <p>详情内容:</p> <div style="border: 1px solid #ccc; margin-top: 10px"> <!-- 工具栏 --> <Toolbar :defaultConfig="Editors.toolbarConfig" :editor="Editors.editor" style="border-bottom: 1px solid #ccc" /> <!-- 编辑器 --> <Editor v-model="form.productDescribe" :defaultConfig="Editors.editorConfig" style="height: 400px; overflow-y: hidden" @onChange="onChange" @onCreated="onCreated" /> </div> </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 { getProductlist, getProductone, putProduct, delProduct, exportProduct, addProduct, } from "@/api/ops/vip/product.js"; import { Editor, Toolbar } from "@wangeditor/editor-for-vue"; import { getToken } from "@/utils/auth"; import Dict from "@/views/system/dict/index.vue"; export default { name: "Product", components: { Dict, Editor, Toolbar }, dicts: ["sys_normal_disable","product_type","commen_status0", "income_type","product_income_way","product_cycle_type","sys_wallet_type"], data() { return { // 富文本内容 Editors: { editor: null, html: "hellow", toolbarConfig: {}, editorConfig: { placeholder: "请输入内容...", MENU_CONF: {} }, mode: "default", // or 'simple'}, }, // 状态 status: "", // 遮罩层 loading: true, // 选中数组 ids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 产品表格数据 productList: [], // 弹出层标题 title: "", // 是否显示弹出层 dialogFormVisible: false, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, productName: null, status: null, productType: null, }, // 表单参数 form: {}, // 表单校验 rules: {}, }; }, created() { this.getList(); }, beforeDestroy() { const editor = this.editor; if (editor == null) return; editor.destroy(); // 组件销毁时,及时销毁编辑器 }, filters: { switchdelFlag(val) { let res; if (val == 0) res = "关闭"; if (val == 1) res = "开启"; return res; }, }, methods: { // 接收富文本内容改变 onCreated(editor) { this.Editors.editor = Object.seal(editor); // 一定要用 Object.seal() ,否则会报错 }, onChange(editor) { // console.log('onChange', editor.getHtml()) // onChange 时获取编辑器最新内容 }, getEditorText() { const editor = this.Editors.editor; if (editor == null) return; console.log(editor.getText()); // 执行 editor API }, printEditorHtml() { const editor = this.Editors.editor; if (editor == null) return; console.log(editor.getHtml()); // 执行 editor API }, /** 查询产品列表 */ getList() { this.loading = true; getProductlist(this.queryParams).then((res) => { this.productList = res.rows; // console.log(this.productList); this.total = res.total; this.loading = false; }); }, // 取消按钮 cancel() { this.dialogFormVisible = false; this.reset(); }, // 提交后图片格式化 // 表单重置 reset() { this.form = { pageNum: 1, pageSize: 10, productType: null, status: null, }; this.resetForm("form"); }, /** 搜索按钮操作 */ handleQuery() { //搜索 this.queryParams.pageNum = 1; this.getList(); }, /** 重置按钮操作 */ resetQuery() { console.log(210); this.resetForm("queryForm"); this.reset(); this.queryParams.status = null; this.queryParams.productType = null; this.handleQuery(); }, // 多选框选中数据 handleSelectionChange(selection) { console.log(216); // this.ids = selection.map(item => item.productId) // this.single = selection.length!==1 // this.multiple = !selection.length }, // 跳转下一级 next(row) { let data = { productKey: row.productKey, }; // console.log(row) this.$router.push({ path: "/vip/prddetails", query: data }); }, /** 新增按钮操作 */ handleAdd() { this.reset(); this.dialogFormVisible = true; this.title = "添加产品"; }, /** 修改按钮操作 */ handleUpdate(row) { this.reset(); getProductone(row.productId).then((res) => { this.form = res.data; this.dialogFormVisible = true; this.title = "修改产品"; }); }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate((valid) => { if (valid) { if (this.form.productId != null) { putProduct(this.form).then((response) => { this.$modal.msgSuccess("修改成功"); this.dialogFormVisible = false; this.getList(); }); } else { addProduct(this.form).then((response) => { this.$modal.msgSuccess("新增成功"); this.dialogFormVisible = false; this.getList(); }); } } }); }, /** 删除按钮操作 */ handleDelete(row) { const Ids = row.productId; this.$modal .confirm('是否确认删除产品编号为"' + Ids + '"的数据项?') .then(function () { return delProduct(Ids); }) .then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); }) .catch(() => {}); }, /** 导出按钮操作 */ handleExport() { console.log(422); exportProduct("传参").then((res) => { console.log(res); }); // this.download('ops/product/export', { // ...this.queryParams // }, `product_${new Date().getTime()}.xlsx`) }, }, }; </script> <style src="@wangeditor/editor/dist/css/style.css"></style>