123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <view class="page-body">
-
-
- <view>
- <el-row>
- <el-button type="primary" size="small" icon="el-icon-refresh" @click="refresh">刷新</el-button>
- <el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
- </el-row>
- </view>
-
-
- <vk-data-table ref="table1" :action="table1.action" :columns="table1.columns"
- :right-btns="['detail_auto','update','delete']" :selection="true" :row-no="true" :pagination="true"
- @update="updateBtn" @delete="deleteBtn" @current-change="currentChange" @selection-change="selectionChange">
- </vk-data-table>
-
-
- <vk-data-dialog v-model="form1.props.show" :title="form1.props.title" width="500px" mode="form"
- :close-on-click-modal="false">
- <vk-data-form v-model="form1.data" :rules="form1.props.rules" :action="form1.props.action"
- :form-type="form1.props.formType" :columns='form1.props.columns' label-width="80px"
- @success="form1.props.show = false;refresh();"></vk-data-form>
- </vk-data-dialog>
-
-
- </view>
- </template>
- <script>
- var that;
- var vk = uni.vk;
- var originalForms = {};
- export default {
- data() {
-
- return {
-
- loading: false,
-
- data: {
- },
-
- table1: {
-
- action: "admin/yi/goods/category/sys/getList",
-
- columns: [
- { key: "_id", title: "id", type: "text", width: 120 },
- { key: "name", title: "分类名", type: "text", width: 280 },
- { key: "image", title: "图标", type: "image", width: 100,imageWidth: 80 },
- { key: "sort", title: "排序", type: "text", width: 80, sortable: "custom" },
- {
- key: "status",
- title: "状态",
- type: "switch",
- width: 120,
- activeValue: true,
- inactiveValue: false
- },
- { key: "_add_time", title: "添加时间", type: "time", width: 160, sortable: "custom" },
- { key: "_add_time", title: "距离现在", type: "dateDiff", width: 120 },
- ],
-
- multipleSelection: [],
-
- selectItem: ""
- },
-
-
- form1: {
-
- data: {
- status: true
- },
-
- props: {
-
- action: "",
-
- columns: [
- { key: "name", title: "分类名", type: "text", tips: "不宜过长" },
- { key: "image", title: "图标", type: "file-select", tips: "200*200px" },
- { key: "sort", title: "排序", type: "text", tips: "数字越大越靠前" },
- { key: "status", title: "状态", type: "switch", activeValue: true},
- ],
-
- rules: {
- name: [
-
- { required: true, message: "分类名不能为空", trigger: ['blur', 'change'] }
- ],
- },
-
- formType: "",
-
- show: false
- }
- },
-
- formDatas: {},
-
- };
- },
-
- onLoad(options = {}) {
- that = this;
- vk = that.vk;
- that.options = options;
- that.init(options);
-
- },
-
- onReady() {},
-
- onShow() {},
-
- onHide() {},
-
- methods: {
-
- init(options) {
- originalForms["form1"] = vk.pubfn.copyObject(that.form1);
- },
-
- pageTo(path) {
- vk.navigateTo(path);
- },
-
- resetForm() {
- vk.pubfn.resetForm(originalForms, that);
- },
-
- search() {
- that.$refs.table1.search();
- },
-
- refresh() {
- that.$refs.table1.refresh();
- },
-
- getCurrentRow() {
- return that.$refs.table1.getCurrentRow();
- },
-
- currentChange(val) {
- that.table1.selectItem = val;
- },
-
- selectionChange(list) {
- that.table1.multipleSelection = list;
- },
-
- addBtn() {
- that.resetForm();
- that.form1.props.action = 'admin/yi/goods/category/sys/add';
- that.form1.props.formType = 'add';
- that.form1.props.title = '添加';
- that.form1.props.show = true;
- },
-
- updateBtn({ item }) {
- that.form1.props.action = 'admin/yi/goods/category/sys/update';
- that.form1.props.formType = 'update';
- that.form1.props.title = '编辑';
- that.form1.props.show = true;
- that.form1.data = item;
- },
-
- deleteBtn({ item, deleteFn }) {
- deleteFn({
- action: "admin/yi/goods/category/sys/delete",
- data: {
- _id: item._id
- },
- });
- }
- },
-
- watch: {
- },
-
- filters: {
- },
-
- computed: {
- }
- };
- </script>
- <style lang="scss" scoped>
- .page-body {}
- </style>
|