|
@@ -1,13 +1,239 @@
|
|
<template>
|
|
<template>
|
|
- <div>
|
|
|
|
- 订单列表
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <my-form :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>
|
|
|
|
+ </template>
|
|
|
|
+ </my-form>
|
|
|
|
+ <!-- :hasIndex="hasIndex" -->
|
|
|
|
+ <my-table
|
|
|
|
+ :tableData="tableData"
|
|
|
|
+ :tableConfigArr="tableConfigArr"
|
|
|
|
+ :hasIndex="hasIndex"
|
|
|
|
+ @handlerSelectChange="handlerSelectChange"
|
|
|
|
+ @handlerSelect="handlerSelect"
|
|
|
|
+ @handlerSelectAll="handlerSelectAll"
|
|
|
|
+ >
|
|
|
|
+ <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
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ <template slot-scope="scope" slot="usrname">
|
|
|
|
+ <el-tag size="medium">{{ scope.row.name }}</el-tag>
|
|
|
|
+ </template>
|
|
|
|
+ </my-table>
|
|
|
|
+
|
|
|
|
+ <my-pop
|
|
|
|
+ :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>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
- data() {
|
|
|
|
- return {}
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ dialogFormVisible: false,
|
|
|
|
+ hasIndex: true,
|
|
|
|
+ title: "编辑",
|
|
|
|
+ // hasExpand: true,
|
|
|
|
+ hasSelect: true,
|
|
|
|
+ formValue: {
|
|
|
|
+ name: "",
|
|
|
|
+ address: "",
|
|
|
|
+ },
|
|
|
|
+ formList: [
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "name",
|
|
|
|
+ label: "姓名:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "address",
|
|
|
|
+ label: "地址:",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+
|
|
|
|
+ // 修改用
|
|
|
|
+ formValue1: {
|
|
|
|
+ name: "",
|
|
|
|
+ address: "",
|
|
|
|
+ date: "",
|
|
|
|
+ },
|
|
|
|
+ formList1: [
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "name",
|
|
|
|
+ label: "姓名:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "address",
|
|
|
|
+ label: "地址:",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ type: "input",
|
|
|
|
+ prop: "date",
|
|
|
|
+ label: "时间:",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ tableData: [],
|
|
|
|
+ tableConfigArr: [
|
|
|
|
+ {
|
|
|
|
+ fixed: false,
|
|
|
|
+ prop: "date",
|
|
|
|
+ label: "日期",
|
|
|
|
+ sortable: true,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ // fixed: false,
|
|
|
|
+ // prop: "name",
|
|
|
|
+ // label: "名字",
|
|
|
|
+ slot: "usrname",
|
|
|
|
+ label: "名字",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ fixed: false,
|
|
|
|
+ prop: "address",
|
|
|
|
+ label: "地址",
|
|
|
|
+ width: "300",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ slot: "operate",
|
|
|
|
+ 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.formValue1 = { ...this.formValue1, ...data };
|
|
|
|
+ this.dialogFormVisible = !this.dialogFormVisible;
|
|
|
|
+ },
|
|
|
|
+ add() {
|
|
|
|
+ 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) {
|
|
|
|
+ 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;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ created() {
|
|
|
|
+ this.tableData = [
|
|
|
|
+ {
|
|
|
|
+ id: "1",
|
|
|
|
+ date: "2016-05-02",
|
|
|
|
+ name: "王小虎",
|
|
|
|
+ address: "上海市普陀区金沙江路 1518ssds 弄",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: "2",
|
|
|
|
+ date: "2016-05-04",
|
|
|
|
+ name: "利欧韵",
|
|
|
|
+ address: "上海市普陀区金沙江路 1517 弄",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: "3",
|
|
|
|
+ date: "2016-05-01",
|
|
|
|
+ name: "王小虎",
|
|
|
|
+ address: "上海市普陀区金沙江路 1519 弄",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: "4",
|
|
|
|
+ date: "2016-05-03",
|
|
|
|
+ name: "王小虎",
|
|
|
|
+ address: "上海市普陀区金沙江路 1516 弄",
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ },
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.dialog-footer {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.form_box {
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+::v-deep .el-form-item__content {
|
|
|
|
+ display: flex;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+</style>
|