123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <style lang="less">
- @import '../../styles/common.less';
- .ivu-card-head {
- p {
- height: 32px;
- line-height: 32px;
- }
- button {
- float: right;
- }
- }
- .ivu-table-cell img {
- width: 100%;
- }
- </style>
-
- <template>
- <div>
- <Row class="margin-top-10" v-show="proShow">
- <Col>
- <Card>
- <p slot="title">
- <Icon type="android-remove"></Icon>
- 分类信息
- <Button type="primary" @click="add">新增</Button>
- </p>
- <div class="edittable-table-height-con">
- <Table :columns="columns" :data="prosHandle"></Table>
- <Page :total="total" :page-size="pageSize" @on-change="getData"></Page>
- </div>
- </Card>
- </Col>
- </Row>
- <edit v-show="editShow" @pub-success="pubSuccess" :form-content="formContent"></edit>
- </div>
- </template>
-
- <script>
- import edit from "./edit";
- export default {
- name: 'product',
- components: {
- edit
- },
- computed: {
- editShow() {
- return !this.proShow;
- },
- prosHandle() {
- let products = [].concat(JSON.parse(JSON.stringify(this.products)));
- console.log(products);
- return products;
- }
- },
- data () {
- return {
- total: 0,
- pageSize: 20,
- proShow: true,
- formContent: {},
- columns: [
- {title: "分类名称", key: 'name', align: 'center'},
- {title: "描述信息", key: 'info', align: 'center'},
- {title: "服务标题", key: 'server', align: 'center'},
- {title: "图片位置", key: 'photo', align: 'center',
- render: (h, params) => {
- console.log(params);
- return h('img', {
- attrs: {
- src: params.row.photo
- }
- })
- }
- },
- {title: "显示位置", key: 'location', align: 'center'},
- {
- title: "操作",
- key: "action",
- align: 'center',
- render: (h, params) => {
- return h('div', [
- h('Button', {
- props: {
- type: 'primary',
- size: 'default'
- },
- style: {
- marginRight: '5px'
- },
- on: {
- click: () => {
- let id = params.row.id;
- this.proShow = false;
- this.products.forEach((product) => {
- if (product.id == id) {
- this.formContent = product;
- }
- })
- }
- }
- }, '修改'),
- h('Button', {
- props: {
- type: 'error',
- size: 'default'
- },
- style: {
- marginRight: '5px'
- },
- on: {
- click: () => {
- let id = params.row.id;
- this.axios.delete(`/classify/${id}`)
- .then((res) => {
- this.products = this.products.filter((product) => {
- if (product.id != id) {
- return true;
- }
- });
- });
- }
- }
- }, '删除')
- ]);
- }
- }
- ],
- products: []
- };
- },
- methods: {
- add () {
- this.proShow = false;
- this.formContent = {};
- },
- pubSuccess() {
- this.proShow = true;
- this.getData();
- },
- getData (num) {
- this.axios.get("/classifies", {
- params: {
- page: num || 1
- }
- }).then((res) => {
- this.products = res.data.data;
- this.pageSize = res.data.per_page;
- this.total = res.data.total;
- });
- }
- },
- created () {
- this.getData();
- }
- };
- </script>
|