123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <div class="m-container">
- <h2>
- <div class="squrt"></div>
- 产品管理
- </h2>
- <save-form
- :inline="true"
- class="searchForm"
- ref="searchForm"
- @submit="search"
- @reset="reset"
- size="small"
- :saveKey="'platformProductManager'"
- :model.sync="searchForm"
- >
- <el-form-item :rules="[]">
- <el-input v-model="searchForm.search" placeholder="产品名称"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button native-type="submit" type="danger">搜索</el-button>
- <el-button native-type="reset" type="primary">重置</el-button>
- </el-form-item>
- </save-form>
- <el-button size="small" style="margin-bottom: 20px;" type="primary" v-permission="'platformProduct/add'" @click="openProduct('create')" icon="el-icon-plus">添加</el-button>
- <!-- 列表 -->
- <div class="tableWrap">
- <el-table
- :data="tableList"
- size="small"
- :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
- >
- <el-table-column align="center" label="产品编号" prop="id">
- </el-table-column>
- <el-table-column
- align="center"
- prop="name"
- label="产品名称"
- ></el-table-column>
- <el-table-column align="center" label="产品描述" prop="remark">
- <template slot-scope="scope">
- <tooltip :content="scope.row.remark" />
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作">
- <template slot-scope="scope">
- <el-button
- @click="resetProduct(scope.row)"
- v-permission="'platformProduct/update'"
- type="text"
- size="small"
- >修改</el-button
- >
- <el-button
- @click="delProduct(scope.row)"
- v-permission="'platformProduct/delete'"
- type="text"
- size="small"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <pagination
- :saveKey="'platformProductManager'"
- sync
- :total.sync="pageInfo.total"
- :page.sync="pageInfo.page"
- :limit.sync="pageInfo.limit"
- :page-sizes="pageInfo.page_size"
- @pagination="getList"
- />
- </div>
- <el-dialog
- :title="isAdd ? '新增产品' : '修改产品'"
- class="courseMask"
- width="500px"
- :visible.sync="courseVisible"
- >
- <operationModel
- ref="operationModel"
- :activeRow="activeRow"
- :pageType="pageType"
- v-if="courseVisible"
- @close="close"
- />
- <div slot="footer" class="dialog-footer">
- <el-button size="small" @click="courseVisible = false">取 消</el-button>
- <el-button size="small" type="primary" @click="submitInfo">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import pagination from "@/components/Pagination/index";
- import { platformProductQueryPage,platformProductDelete } from "./api";
- import operationModel from "./operationModel";
- const initSearch = {
- search: null
- };
- export default {
- components: { pagination, operationModel },
- data() {
- return {
- tableList: [],
- pageType: 'create',
- pageInfo: {
- // 分页规则
- limit: 10, // 限制显示条数
- page: 1, // 当前页
- total: 0, // 总条数
- page_size: [10, 20, 40, 50], // 选择限制显示条数
- },
- searchForm: { ...initSearch },
- isAdd: true,
- courseVisible: false,
- activeRow: null,
- };
- },
- mounted() {
- this.$store.dispatch("setBranchs");
- this.getList();
- },
- methods: {
- async getList() {
- try {
- const res = await platformProductQueryPage({
- ...this.searchForm,
- page: this.pageInfo.page,
- rows: this.pageInfo.limit,
- });
- this.pageInfo.total = res.data.total;
- // res.data.rows
- this.tableList = res.data.rows;
- } catch (e) {}
- },
- search() {
- this.pageInfo.page = 1;
- this.$refs.searchForm.save(this.searchForm);
- this.$refs.searchForm.save(this.pageInfo, "page");
- this.getList();
- },
- reset() {
- this.searchForm = { ...initSearch };
- this.search();
- },
- resetProduct(row) {
- this.isAdd = false;
- this.activeRow = row;
- this.pageType = 'update'
- this.courseVisible = true;
- },
- submitInfo() {
- const str = this.isAdd ? "create" : "update";
- this.$refs.operationModel.submitInfo(str);
- },
- close() {
- this.courseVisible = false;
- this.getList();
- },
- openProduct() {
- this.isAdd = true;
- this.activeRow = null;
- this.pageType = 'create'
- this.courseVisible = true;
- },
- async delProduct(row) {
- this.$confirm("是否删除?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then( async() => {
- try{
- const res = await platformProductDelete({ id:row.id})
- this.$message.success('删除成功')
- this.getList()
- }catch{}
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .courseMask .el-dialog__body {
- padding-bottom: 0;
- }
- </style>
|