|
@@ -0,0 +1,294 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <my-form
|
|
|
|
+ v-if="formList.length > 0"
|
|
|
|
+ :formValue="formValue"
|
|
|
|
+ :formList="formList"
|
|
|
|
+ :inline="true"
|
|
|
|
+ >
|
|
|
|
+ <template slot-scope="scope" slot="handle">
|
|
|
|
+ <el-button type="primary" @click="search(scope.formData)"
|
|
|
|
+ >搜索</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" @click="add()">添加</el-button>
|
|
|
|
+ <el-button v-if="exportFlag" type="primary" @click="excl()"
|
|
|
|
+ >导出</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ </my-form>
|
|
|
|
+ <my-table
|
|
|
|
+ v-loading="isLoading"
|
|
|
|
+ element-loading-text="拼命加载中"
|
|
|
|
+ element-loading-spinner="el-icon-loading"
|
|
|
|
+ :api="api"
|
|
|
|
+ :tableData="tableData"
|
|
|
|
+ :tableConfigArr="tableConfigArr"
|
|
|
|
+ :hasIndex="hasIndex"
|
|
|
|
+ @handlerSelectChange="handlerSelectChange"
|
|
|
|
+ @handlerSelect="handlerSelect"
|
|
|
|
+ @handlerSelectAll="handlerSelectAll"
|
|
|
|
+ >
|
|
|
|
+ <!-- <template
|
|
|
|
+ v-for="items in tableConfigArr"
|
|
|
|
+ v-if="items.slot"
|
|
|
|
+ slot-scope="scope"
|
|
|
|
+ >
|
|
|
|
+ <div v-if="items.slot == 'operate'" slot="operate">
|
|
|
|
+ <slot name="operate" :row="scope.row"></slot>
|
|
|
|
+ </div>
|
|
|
|
+ </template> -->
|
|
|
|
+
|
|
|
|
+ <template slot-scope="scope" slot="operate">
|
|
|
|
+ <!-- <el-button type="primary" size="small" @click="edit(scope.row)"
|
|
|
|
+ >修改</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button type="primary" size="small" @click="deleteUser(scope.row)"
|
|
|
|
+ >删除</el-button
|
|
|
|
+ > -->
|
|
|
|
+ <slot name="operate" :row="scope.row"></slot>
|
|
|
|
+ </template>
|
|
|
|
+ <template slot-scope="scope" slot="usrname">
|
|
|
|
+ <el-tag size="medium">{{ scope.row.name }}</el-tag>
|
|
|
|
+ </template>
|
|
|
|
+ </my-table>
|
|
|
|
+ <slot></slot>
|
|
|
|
+ <div class="end">
|
|
|
|
+ <el-pagination
|
|
|
|
+ background
|
|
|
|
+ :pager-count="5"
|
|
|
|
+ layout="total,sizes,prev,pager,next,jumper"
|
|
|
|
+ :total="50"
|
|
|
|
+ :currentPage="currentPage"
|
|
|
|
+ :page-sizes="[5, 10, 20, 50]"
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
|
+ >
|
|
|
|
+ </el-pagination>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <my-pop
|
|
|
|
+ class="pop_box"
|
|
|
|
+ :title="title"
|
|
|
|
+ :dialogFormVisible="dialogFormVisible"
|
|
|
|
+ @handleClose="handleClose"
|
|
|
|
+ >
|
|
|
|
+ <my-form :formValue="formValue1" :formList="formList1" class="form_box">
|
|
|
|
+ </my-form>
|
|
|
|
+ <div class="dialog-footer">
|
|
|
|
+ <slot name="footer">
|
|
|
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
|
+ <el-button @click="confirm(formValue1)" type="primary"
|
|
|
|
+ >确定</el-button
|
|
|
|
+ >
|
|
|
|
+ </slot>
|
|
|
|
+ </div>
|
|
|
|
+ </my-pop>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import apiSend from "../../apirequest/http.js";
|
|
|
|
+export default {
|
|
|
|
+ name: "order-list",
|
|
|
|
+ props: {
|
|
|
|
+ // 搜索的字段
|
|
|
|
+ formValue: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: function () {
|
|
|
|
+ return {};
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // 搜索的配置
|
|
|
|
+ formList: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: function () {
|
|
|
|
+ return [];
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // 搜索的配置
|
|
|
|
+ exportFlag: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: function () {
|
|
|
|
+ return false;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // 配置table
|
|
|
|
+ tableConfigArr: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: function () {
|
|
|
|
+ return [];
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // 控制table序号
|
|
|
|
+ hasIndex: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: function () {
|
|
|
|
+ return false;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ api: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: function () {
|
|
|
|
+ return "";
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ tableData: [],
|
|
|
|
+ isLoading: false,
|
|
|
|
+ dialogFormVisible: false,
|
|
|
|
+ title: "编辑",
|
|
|
|
+ currentPage: 1,
|
|
|
|
+ // 修改用
|
|
|
|
+ formValue1: {
|
|
|
|
+ name: "",
|
|
|
|
+ address: "",
|
|
|
|
+ date: "",
|
|
|
|
+ },
|
|
|
|
+ formList1: [
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "name",
|
|
|
|
+ label: "姓名:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "address",
|
|
|
|
+ label: "地址:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "date",
|
|
|
|
+ label: "时间:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "richText",
|
|
|
|
+ prop: "richText",
|
|
|
|
+ label: "正文:",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ formInline: {
|
|
|
|
+ user: "",
|
|
|
|
+ region: "",
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ methods: {
|
|
|
|
+ handlerSelectChange(data) {
|
|
|
|
+ console.log(data, "handlerSelectChange");
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handlerSelect(data) {
|
|
|
|
+ console.log(data, "handlerSelect");
|
|
|
|
+ },
|
|
|
|
+ handlerSelectAll(data) {
|
|
|
|
+ this.allSelect = data;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ search(data) {
|
|
|
|
+ console.log(data, "搜索的数据");
|
|
|
|
+ },
|
|
|
|
+ edit(data) {
|
|
|
|
+ console.log(data, "改");
|
|
|
|
+ this.title = "编辑";
|
|
|
|
+ this.formValue1 = { ...this.formValue1, ...data };
|
|
|
|
+ this.dialogFormVisible = !this.dialogFormVisible;
|
|
|
|
+ },
|
|
|
|
+ add() {
|
|
|
|
+ this.title = "添加";
|
|
|
|
+ this.formValue1 = {
|
|
|
|
+ name: "",
|
|
|
|
+ address: "",
|
|
|
|
+ date: "",
|
|
|
|
+ };
|
|
|
|
+ this.dialogFormVisible = !this.dialogFormVisible;
|
|
|
|
+ },
|
|
|
|
+ deleteUser(data) {
|
|
|
|
+ let index = this.tableData.findIndex((item) => {
|
|
|
|
+ return item.id == data.id;
|
|
|
|
+ });
|
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+ confirm(data) {
|
|
|
|
+ console.log(data, "11111");
|
|
|
|
+ this.dialogFormVisible = !this.dialogFormVisible;
|
|
|
|
+ if (data.id) {
|
|
|
|
+ let index = this.tableData.findIndex((item) => {
|
|
|
|
+ return item.id == data.id;
|
|
|
|
+ });
|
|
|
|
+ console.log(index);
|
|
|
|
+ this.tableData.forEach((item) => {
|
|
|
|
+ this.$set(this.tableData, index, this.formValue1);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ console.log(this.tableData, "变化了么");
|
|
|
|
+ } else {
|
|
|
|
+ let datas = {
|
|
|
|
+ ...data,
|
|
|
|
+ ...{ id: (this.tableData.length + 1).toString },
|
|
|
|
+ };
|
|
|
|
+ this.tableData.push(datas);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleClose() {
|
|
|
|
+ this.dialogFormVisible = false;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleSizeChange() {},
|
|
|
|
+ handleCurrentChange() {},
|
|
|
|
+ excl() {
|
|
|
|
+ this.list();
|
|
|
|
+ },
|
|
|
|
+ async list() {
|
|
|
|
+ this.isLoading = true;
|
|
|
|
+
|
|
|
|
+ let result = await apiSend.get(this.api);
|
|
|
|
+ if (result && result.code == 0) {
|
|
|
|
+ this.tableData = result.data.tableData;
|
|
|
|
+ this.isLoading = false;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ created() {
|
|
|
|
+ this.list();
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.dialog-footer {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+::v-deep .pop_box .el-form-item__content {
|
|
|
|
+ display: flex;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.end {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ margin-top: 1%;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+::v-deep .el-loading-spinner .el-loading-text {
|
|
|
|
+ color: #e9021d;
|
|
|
|
+ margin: 3px 0;
|
|
|
|
+ font-size: 14px;
|
|
|
|
+}
|
|
|
|
+::v-deep .el-icon-loading {
|
|
|
|
+ background: url(../../assets/loading.png) center no-repeat;
|
|
|
|
+ background-size: cover;
|
|
|
|
+ width: 25px;
|
|
|
|
+ height: 25px;
|
|
|
|
+}
|
|
|
|
+::v-deep .el-icon-loading:before {
|
|
|
|
+ content: "替";
|
|
|
|
+ visibility: hidden;
|
|
|
|
+}
|
|
|
|
+</style>
|