liu 6 år sedan
förälder
incheckning
71c4fc0bcf

+ 21
- 0
hksystem/src/components/edit/index.js Visa fil

@@ -0,0 +1,21 @@
1
+import EditComponent from "./index.vue";
2
+
3
+const Edit = {};
4
+
5
+Edit.install = (Vue) => {
6
+    const EditConstructor = Vue.extend(EditComponent);;
7
+    const instance = new EditConstructor();
8
+
9
+    instance.$mount(document.createElement('div'));
10
+    document.body.appendChild(instance.$el);
11
+
12
+    Vue.$edit = () => {
13
+        instance.show = true;
14
+    }
15
+    Vue.prototype.$edit = (opt) => {
16
+        instance.opt = opt;
17
+        instance.show = true;
18
+    }
19
+}
20
+
21
+export default Edit;

+ 57
- 0
hksystem/src/components/edit/index.vue Visa fil

@@ -0,0 +1,57 @@
1
+<style lang="less">
2
+
3
+</style>
4
+
5
+<template>
6
+    <Modal v-model="show" :loading="loading" :closable="false">
7
+        <p slot="header">
8
+            <Icon type="information-circled"></Icon>
9
+            <span>修改</span>
10
+        </p>
11
+        <div>
12
+            <Form ref="form" :label-width="80">
13
+                <FormItem label="分类">
14
+                    <Input v-model="classify" />
15
+                </FormItem>
16
+            </Form>
17
+        </div>
18
+        <div slot="footer">
19
+            <Button type="primary" @click="submit">确定</Button>
20
+        </div>
21
+    </Modal>
22
+</template>
23
+
24
+<script>
25
+export default {
26
+    name: 'edit',
27
+    data() {
28
+        return {
29
+            loading: true,
30
+            opt: {},
31
+            classify: '',
32
+            show: false
33
+        }
34
+    },
35
+    methods: {
36
+        submit() {
37
+            if (!this.classify) {
38
+                this.show = true;
39
+                return;
40
+            }
41
+            if (this.opt.classifys && this.opt.classifys.length > 0) {
42
+                this.opt.classifys.forEach((classify, i) => {
43
+                    if (classify == this.classify) {
44
+                        // this.opt.classifys[i] = this.classify;
45
+                    }
46
+                })
47
+            }
48
+            this.axios.post("/product_classify/store", {
49
+                classify: this.classify
50
+            }).then((res) => {
51
+                this.show = false;
52
+                this.loading = false;
53
+            });
54
+        }
55
+    }
56
+};
57
+</script>

+ 2
- 0
hksystem/src/main.js Visa fil

@@ -10,10 +10,12 @@ import 'iview/dist/styles/iview.css';
10 10
 import VueI18n from 'vue-i18n';
11 11
 import util from '@/libs/util';
12 12
 import Login from '@/components/login';
13
+import Edit from '@/components/edit';
13 14
 
14 15
 Vue.use(VueI18n);
15 16
 Vue.use(iView);
16 17
 Vue.use(Login);
18
+Vue.use(Edit);
17 19
 Vue.prototype.$message = Message
18 20
 Vue.prototype.$Message = Message
19 21
 Vue.prototype.axios = util.ajax;

+ 15
- 6
hksystem/src/router/router.js Visa fil

@@ -113,13 +113,22 @@ export const appRouter = [{
113 113
         title: '母婴产品管理',
114 114
         component: Main,
115 115
         children: [{
116
-            path: 'index',
117
-            title: '产品管理',
118
-            name: 'product_index',
119
-            component: resolve => {
120
-                require(['@/views/product/index.vue'], resolve);
116
+                path: 'classify',
117
+                title: '产品分类',
118
+                name: 'product_classify',
119
+                component: resolve => {
120
+                    require(['@/views/product-classify/index.vue'], resolve);
121
+                },
122
+            },
123
+            {
124
+                path: 'index',
125
+                title: '产品管理',
126
+                name: 'product_index',
127
+                component: resolve => {
128
+                    require(['@/views/product/index.vue'], resolve);
129
+                }
121 130
             }
122
-        }]
131
+        ]
123 132
     },
124 133
     {
125 134
         path: '/service',

+ 1
- 1
hksystem/src/views/housekeeper/detail.vue Visa fil

@@ -7,7 +7,7 @@
7 7
         <Row>
8 8
             <Col span="18">
9 9
                 <Card>
10
-                    <Form :label-width="80">
10
+                    <Form :label-width="100">
11 11
                         <FormItem label="分类1:">
12 12
                             <span>{{formContent.classify1}}</span>
13 13
                         </FormItem>

+ 1
- 1
hksystem/src/views/matron/detail.vue Visa fil

@@ -7,7 +7,7 @@
7 7
         <Row>
8 8
             <Col span="18">
9 9
                 <Card>
10
-                    <Form :label-width="80">
10
+                    <Form :label-width="100">
11 11
                         <FormItem label="月嫂等级:">
12 12
                             <span>{{formContent.level}}</span>
13 13
                         </FormItem>

+ 1
- 0
hksystem/src/views/matron/index.vue Visa fil

@@ -125,6 +125,7 @@ export default {
125 125
                                                         return true;
126 126
                                                     }
127 127
                                                 });
128
+                                                this.$message.success("删除成功");
128 129
                                             });
129 130
                                     }
130 131
                                 }

+ 70
- 0
hksystem/src/views/product-classify/edit.vue Visa fil

@@ -0,0 +1,70 @@
1
+<style lang="less">
2
+
3
+</style>
4
+
5
+<template>
6
+    <Modal v-model="editModal" :loading="loading" :closable="false">
7
+        <p slot="header">
8
+            <Icon type="information-circled"></Icon>
9
+            <span>修改</span>
10
+        </p>
11
+        <div>
12
+            <Form ref="form" :label-width="80">
13
+                <FormItem label="分类">
14
+                    <Input v-model="classify" />
15
+                </FormItem>
16
+            </Form>
17
+        </div>
18
+        <div slot="footer">
19
+            <Button type="primary" @click="submit">确定</Button>
20
+        </div>
21
+    </Modal>
22
+</template>
23
+
24
+<script>
25
+export default {
26
+    name: 'edit',
27
+    data() {
28
+        return {
29
+            loading: true,
30
+            id: this.row.id,
31
+            classify: this.row.classify,
32
+            editModal: false
33
+        }
34
+    },
35
+    watch: {
36
+        row() {
37
+            this.classify = this.row.classify;
38
+            this.id = this.row.id;
39
+        },
40
+        editShow() {
41
+            this.editModal = this.editShow;
42
+        }
43
+    },
44
+    props: {
45
+        editClassify: Array,
46
+        editShow: Boolean,
47
+        row: Object
48
+    },
49
+    methods: {
50
+        submit() {
51
+            let classifys = [];
52
+            let editClassify = [];
53
+            this.editClassify.forEach((data) => {
54
+                if (data.id == this.id) {
55
+                    data.classify = this.classify
56
+                }
57
+                editClassify.push(data.classify);
58
+                classifys.push(data);
59
+            });
60
+            let classify_str = editClassify.join("");
61
+            this.axios.post("/product_classify/store", {
62
+                classify: classify_str
63
+            }).then((res) => {
64
+                this.$emit("close", {classifys: classifys});
65
+                this.loading = false;
66
+            });
67
+        }
68
+    }
69
+};
70
+</script>

+ 144
- 0
hksystem/src/views/product-classify/index.vue Visa fil

@@ -0,0 +1,144 @@
1
+<style lang="less">
2
+    @import '../../styles/common.less';
3
+    .ivu-card-head {
4
+        p {
5
+            height: 32px;
6
+            line-height: 32px;
7
+        }
8
+        button {
9
+            float: right;
10
+        }
11
+    }
12
+</style>
13
+
14
+<template>
15
+    <div>
16
+        <Row class="margin-top-10" v-show="proShow">
17
+            <Col>
18
+                <Card>
19
+                    <p slot="title">
20
+                        <Icon type="android-remove"></Icon>
21
+                        产品分类
22
+                        <Button type="primary" @click="add">新增</Button>
23
+                    </p>
24
+                    <div class="edittable-table-height-con">
25
+                        <Table :columns="columns" :data="prosHandle"></Table>
26
+                        <Page :total="total" :page-size="pageSize" @on-change="getData"></Page>
27
+                    </div>
28
+                </Card>
29
+            </Col>
30
+        </Row>
31
+        <edit :editShow="editShow" :editClassify="prosHandle" :row="row" @close="closeModal"></edit>
32
+    </div>
33
+</template>
34
+
35
+<script>
36
+import edit from './edit';
37
+export default {
38
+    name: 'classify',
39
+    components: {
40
+        edit
41
+    },
42
+    computed: {
43
+        prosHandle() {
44
+            let products = [];
45
+            this.products.forEach((product, index) => {
46
+                products.push({
47
+                    id: ++index,
48
+                    classify: product
49
+                });
50
+            });
51
+            return products;
52
+        }
53
+    },
54
+    data () {
55
+        return {
56
+            row: {},
57
+            total: 0,
58
+            pageSize: 20,
59
+            proShow: true,
60
+            editShow: false,
61
+            formContent: {},
62
+            columns: [
63
+                {title: "序号", key: 'id'},
64
+                {title: "产品分类", key: 'classify', align: 'center'},
65
+                {
66
+                    title: "操作",
67
+                    key: "action",
68
+                    align: 'center',
69
+                    render: (h, params) => {
70
+                        return h('div', [
71
+                            h('Button', {
72
+                                props: {
73
+                                    type: 'primary',
74
+                                    size: 'default'
75
+                                },
76
+                                style: {
77
+                                    marginRight: '5px'
78
+                                },
79
+                                on: {
80
+                                    click: () => {
81
+                                        this.row = params.row;
82
+                                        this.editShow = true;
83
+                                    }
84
+                                }
85
+                            }, '修改'),
86
+                            h('Button', {
87
+                                props: {
88
+                                    type: 'error',
89
+                                    size: 'default'
90
+                                },
91
+                                style: {
92
+                                    marginRight: '5px'
93
+                                },
94
+                                on: {
95
+                                    click: () => {
96
+                                        let classify = params.row.classify;
97
+                                        this.products = this.products.filter((product) => {
98
+                                            return product != classify;
99
+                                        });
100
+                                        this.axios.post("product_classify/store", {
101
+                                            classify: this.products.join(",")
102
+                                        }).then((res) => {
103
+                                            this.$message.success("删除成功");
104
+                                        });
105
+                                    }
106
+                                }
107
+                            }, '删除')
108
+                        ]);
109
+                    }
110
+                }
111
+            ],
112
+            products: []
113
+        };
114
+    },
115
+    methods: {
116
+        add () {
117
+            this.proShow = false;
118
+            this.formContent = {};
119
+        },
120
+        pubSuccess() {
121
+            this.proShow = true;
122
+            this.getData();
123
+        },
124
+        getData (num) {
125
+            this.axios.get("product_classify", {
126
+                params: {
127
+                    page: num || 1
128
+                }
129
+            }).then((res) => {
130
+                this.products = res.data.data;
131
+                this.pageSize = res.data.per_page;
132
+                this.total = res.data.total;
133
+            });
134
+        },
135
+        closeModal(row) {
136
+            this.editShow = false;
137
+            this.products = row.classifys;
138
+        },
139
+    },
140
+    created () {
141
+        this.getData();
142
+    }
143
+};
144
+</script>

+ 1
- 1
hksystem/src/views/product-order/detail.vue Visa fil

@@ -7,7 +7,7 @@
7 7
         <Row>
8 8
             <Col span="18">
9 9
                 <Card>
10
-                    <Form :label-width="80">
10
+                    <Form :label-width="100">
11 11
                         <FormItem label="产品id:">
12 12
                             <span>{{formContent.product_id}}</span>
13 13
                         </FormItem>

+ 15
- 2
hksystem/src/views/product/edit.vue Visa fil

@@ -18,7 +18,10 @@
18 18
                             <Input v-model="form.price" icon="android-list"/>
19 19
                         </FormItem>
20 20
                         <FormItem label="产品分类">
21
-                            <Input v-model="form.classify" icon="android-list"/>
21
+                            <Select v-model="form.classify">
22
+                                <Option v-for="classify in classifys" :value="classify" :key="classify">{{classify}}</Option>
23
+                            </Select>
24
+                            <!-- <Input v-model="form.classify" icon="android-list"/> -->
22 25
                         </FormItem>
23 26
                         <FormItem label="产品状态">
24 27
                             <Select v-model="form.status" style="width: 150px">
@@ -61,7 +64,8 @@ export default {
61 64
     data () {
62 65
         return {
63 66
             form: this.formContent,
64
-            publishLoading: false
67
+            publishLoading: false,
68
+            classifys: []
65 69
         };
66 70
     },
67 71
     methods: {
@@ -93,7 +97,16 @@ export default {
93 97
                 this.$Message.error('请完善所有信息!');
94 98
                 this.publishLoading = false;
95 99
             }
100
+        },
101
+        getData() {
102
+            this.axios.get("/product_classify")
103
+                .then((res) => {
104
+                    this.classifys = res.data.data;
105
+                });
96 106
         }
107
+    },
108
+    mounted() {
109
+        this.getData();
97 110
     }
98 111
 };
99 112
 </script>

Loading…
Avbryt
Spara