韦创卫 1 year ago
parent
commit
49d784d27d
  1. 1
      pages.json
  2. 338
      pages/contract/template/list.vue
  3. 2
      pages_template/components/table/table-easy.vue

1
pages.json

@ -6,6 +6,7 @@
{ "path": "pages/config/site"},
{ "path": "pages/enquiry/template/list"},
{ "path": "pages/enquiry/attributes/list"},
{ "path": "pages/contract/template/list"},
{
"path": "pages/login/index",
"style": {

338
pages/contract/template/list.vue

@ -0,0 +1,338 @@
<template>
<view class="page-body">
<!-- 页面内容开始 -->
<!-- 表格搜索组件开始 -->
<vk-data-table-query v-model="queryForm1.formData" :columns="queryForm1.columns"
@search="search"></vk-data-table-query>
<!-- 表格搜索组件结束 -->
<!-- 自定义按钮区域开始 -->
<view>
<el-row>
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
<!-- 批量操作 -->
<el-dropdown v-if="table1.multipleSelection" :split-button="false" trigger="click" @command="batchBtn">
<!-- <el-button type="danger" size="small" style="margin-left: 20rpx;"
:disabled="table1.multipleSelection.length === 0">
批量操作<i class="el-icon-arrow-down el-icon--right"></i>
</el-button> -->
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item :command="1">批量操作1</el-dropdown-item>
<el-dropdown-item :command="2">批量操作2</el-dropdown-item> -->
</el-dropdown-menu>
</el-dropdown>
</el-row>
</view>
<!-- 自定义按钮区域结束 -->
<!-- 表格组件开始 -->
<vk-data-table ref="table1" :action="table1.action" :columns="table1.columns" :query-form-param="queryForm1"
:right-btns="['detail_auto','update','delete']" :default-expand-all="false" @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="120px"
@success="form1.props.show = false;refresh();"></vk-data-form>
</vk-data-dialog>
<!-- 添加或编辑的弹窗结束 -->
<!-- 页面内容结束 -->
</view>
</template>
<script>
var that; //
var vk = uni.vk; // vk
var originalForms = {}; //
export default {
data() {
//
return {
//
loading: false,
// init
data: {
},
// -----------------------------------------------------------
table1: {
//
action: "admin/contract/template/sys/getList",
//
columns: [
// {
// key: "_id",
// title: "id",
// type: "text",
// width: 220
// },
{
key: "name",
title: "名称",
type: "text",
width: 220,
align: "left",
},
// {
// key: "parent_id",
// title: "id",
// type: "text",
// width: 220,
// },
{
key: "remark",
title: "备注",
type: "text",
align: "left",
width: 220
},
{
key: "sort",
title: "排序",
type: "number",
align: "left",
width: 80,
},
{
key: "_add_time",
title: "添加时间",
type: "time",
align: "left",
width: 160,
sortable: "custom"
},
{
key: "_add_time",
title: "距离现在",
type: "dateDiff",
align: "left",
width: 120
},
],
//
multipleSelection: [],
//
selectItem: ""
},
// -----------------------------------------------------------
// -----------------------------------------------------------
//
queryForm1: {
//
formData: {
},
// fieldName:,key
columns: [
// {
// key: "name",
// title: "",
// type: "text",
// width: 160,
// mode: "%%"
// },
// {
// key: "remark",
// title: "",
// type: "text",
// width: 160,
// mode: "%%"
// },
// {
// key: "_add_time",
// title: "",
// type: "datetimerange",
// width: 400,
// mode: "[]"
// },
]
},
form1: {
//
data: {
sort: 0
},
//
props: {
//
action: "",
//
columns: [{
key: "name",
title: "名称",
type: "text",
placeholder: "请输入分类名称"
},
{
key: "icon",
title: "图标",
type: "icon",
placeholder: "请选择图标"
},
{
key: "parent_id",
title: "上级分类",
type: "tree-select",
placeholder: "请选择上级分类",
action: "admin/spot/category/sys/getTree",
props: {
list: "rows",
value: "_id",
label: "name",
children: "children"
},
},
{
key: "remark",
title: "备注",
type: "textarea",
maxlength: "99",
showWordLimit: true,
autosize: {
minRows: 2,
maxRows: 10
},
},
{
key: "sort",
title: "排序",
type: "number",
precision: 0,
placeholder: "请输入排序值",
},
],
//
rules: {
sort: [{
type: 'number',
message: '排序值必须为数字'
}],
name:[
{ required:true, message:'分类名称不能为空', trigger:'blur' },
],
},
// add update
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/contract/template/sys/add';
that.form1.props.formType = 'add';
that.form1.props.title = '添加';
that.form1.props.show = true;
},
//
updateBtn({
item
}) {
that.form1.props.action = 'admin/contract/template/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/contract/template/sys/delete",
data: {
_id: item._id
},
});
},
// -
batchBtn(index) {
switch (index) {
case 1:
vk.toast("批量操作按钮1");
break;
case 2:
vk.toast("批量操作按钮2");
break;
default:
break;
}
}
},
//
watch: {
},
//
filters: {
},
//
computed: {
}
};
</script>
<style lang="scss" scoped>
.page-body {}
</style>

2
pages_template/components/table/table-easy.vue

@ -126,7 +126,7 @@
queryForm1:{
//
formData:{
},
// fieldName:,key
columns:[

Loading…
Cancel
Save