From 03df59a72de4354fcc731675c53dd2805c2ec8b1 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 21 Jul 2022 17:26:02 +0800
Subject: [PATCH] 数据新增调整
---
src/views/hd/hd.vue | 784 +++++++++++++++++++++++++++----------------------------
1 files changed, 390 insertions(+), 394 deletions(-)
diff --git a/src/views/hd/hd.vue b/src/views/hd/hd.vue
index 3eed541..35c4384 100644
--- a/src/views/hd/hd.vue
+++ b/src/views/hd/hd.vue
@@ -1,26 +1,26 @@
<template>
- <basic-container>
- <avue-crud
- :option="option"
- :table-loading="loading"
- :data="data"
- :page.sync="page"
- :permission="permissionList"
- :before-open="beforeOpen"
- v-model="form"
- ref="crud"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @row-del="rowDel"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- >
- <!-- <template slot="menuLeft">
+ <basic-container>
+ <avue-crud
+ :option="option"
+ :table-loading="loading"
+ :data="data"
+ :page.sync="page"
+ :permission="permissionList"
+ :before-open="beforeOpen"
+ v-model="form"
+ ref="crud"
+ @row-update="rowUpdate"
+ @row-save="rowSave"
+ @row-del="rowDel"
+ @search-change="searchChange"
+ @search-reset="searchReset"
+ @selection-change="selectionChange"
+ @current-change="currentChange"
+ @size-change="sizeChange"
+ @refresh-change="refreshChange"
+ @on-load="onLoad"
+ >
+ <!-- <template slot="menuLeft">
<el-button
type="danger"
size="small"
@@ -30,406 +30,402 @@
@click="handleDelete"
>删 除
</el-button>
- </template> -->
- <template slot-scope="{ type, disabled }" slot="lineForm">
- <getMapDataInThere
- ref="getMapData"
- id="getMapData"
- @setMapData="setMapData"
- ></getMapDataInThere>
- </template>
- </avue-crud>
- </basic-container>
+ </template>-->
+ <template slot-scope="{ type, disabled }" slot="lineForm">
+ <getMapDataInThere ref="getMapData" id="getMapData" @setMapData="setMapData"></getMapDataInThere>
+ </template>
+ </avue-crud>
+ </basic-container>
</template>
<script>
-import { getList, getDetail, add, update, remove } from "@/api/hd/hd";
-import { mapGetters } from "vuex";
+import { getList, getDetail, add, update, remove } from "@/api/hd/hd"
+import { mapGetters } from "vuex"
// import Map from "@/components/map/main.vue";
-import getMapData from "./getMapData.vue";
-import getMapDataInThere from "./getMapDataInThere.vue";
+import getMapData from "./getMapData.vue"
+import getMapDataInThere from "./getMapDataInThere.vue"
export default {
- components: {
- // Map,
- getMapData,
- getMapDataInThere,
- },
- data() {
- return {
- form: {},
- query: {},
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0,
- },
- selectionList: [],
- option: {
- height: "auto",
- calcHeight: 30,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- viewBtn: true,
- align: "center",
- selection: true,
- indexLabel: "序号",
- dialogClickModal: false,
- column: [
- {
- label: "活动名称",
- prop: "hdname",
- editDisabled: true,
- rules: [
- {
- required: true,
- message: "请输入活动名称",
- trigger: "blur",
- },
- ],
- },
- {
- label: "主办方",
- prop: "sponsor",
- editDisabled: true,
- rules: [
- {
- required: true,
- message: "请输入主办方",
- trigger: "blur",
- },
- ],
- },
- {
- label: "承办方",
- prop: "undertake",
- editDisabled: true,
- rules: [
- {
- required: true,
- message: "请输入承办方",
- trigger: "blur",
- },
- ],
- },
- // {
- // label: "活动地点",
- // viewDisply:false,
- // addDisplay: false,
- // hide: true,
- // editDisply: false,
- // prop: "address",
- // },
- {
- label: "时间",
- prop: "time",
- type: "datetime",
- span: 8,
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- mock: {
- type: "datetime",
- format: "yyyy-MM-dd hh:mm:ss",
- now: true,
- },
- },
- {
- label: "图片",
- prop: "tpurl",
- // dataType: 'string',
- type: "upload",
- propsHttp: {
- res: "data",
- url: "link",
- },
- span: 24,
- listType: "picture-card",
- tip: "只能上传jpg/png文件,且不超过500kb",
- action: "/api/blade-resource/oss/endpoint/put-file",
- },
- {
- label: "介绍",
- prop: "context",
- component: "AvueUeditor",
- options: {
- action: "/api/blade-resource/oss/endpoint/put-file",
- props: {
- res: "data",
- url: "link",
- },
- },
- minRows: 5,
- span: 24,
- },
- {
- label: "选择路径和标点",
- labelWidth: "0",
- prop: "line",
- className: "mapClass",
- hide: true,
- display: true,
- span: 24,
- formslot: true,
- addDisplay: true,
- },
- // {
- // label: "路线",活动
- // hide: true,
- // prop: "lx",
- // editDisply: false,
- // addDisplay: false,
- // },
- ],
- },
- data: [],
- LineData: [],
- PointData: [],
- };
- },
- // watch: {
- // rotesData() {
- // console.log(this.rotesData);
- // },
- // pointData() {
- // console.log(this.pointData);
- // },
- // },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.hd_add, false),
- viewBtn: this.vaildData(this.permission.hd_view, false),
- delBtn: this.vaildData(this.permission.hd_delete, false),
- editBtn: this.vaildData(this.permission.hd_edit, false),
- };
+ components: {
+ // Map,
+ getMapData,
+ getMapDataInThere,
},
- ids() {
- let ids = [];
- this.selectionList.forEach((ele) => {
- ids.push(ele.id);
- });
- return ids.join(",");
+ data () {
+ return {
+ form: {},
+ query: {},
+ loading: true,
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
+ selectionList: [],
+ option: {
+ height: "auto",
+ calcHeight: 30,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: true,
+ index: true,
+ viewBtn: true,
+ align: "center",
+ selection: true,
+ indexLabel: "序号",
+ dialogClickModal: false,
+ column: [
+ {
+ label: "活动名称",
+ prop: "hdname",
+ editDisabled: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入活动名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "主办方",
+ prop: "sponsor",
+ editDisabled: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入主办方",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "承办方",
+ prop: "undertake",
+ editDisabled: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入承办方",
+ trigger: "blur",
+ },
+ ],
+ },
+ // {
+ // label: "活动地点",
+ // viewDisply:false,
+ // addDisplay: false,
+ // hide: true,
+ // editDisply: false,
+ // prop: "address",
+ // },
+ {
+ label: "时间",
+ prop: "time",
+ type: "datetime",
+ span: 8,
+ format: "yyyy-MM-dd hh:mm:ss",
+ valueFormat: "yyyy-MM-dd hh:mm:ss",
+ mock: {
+ type: "datetime",
+ format: "yyyy-MM-dd hh:mm:ss",
+ now: true,
+ },
+ },
+ {
+ label: "图片",
+ prop: "tpurl",
+ // dataType: 'string',
+ type: "upload",
+ propsHttp: {
+ res: "data",
+ url: "link",
+ },
+ span: 24,
+ listType: "picture-card",
+ tip: "只能上传jpg/png文件,且不超过500kb",
+ action: "/api/blade-resource/oss/endpoint/put-file",
+ },
+ {
+ label: "介绍",
+ prop: "context",
+ component: "AvueUeditor",
+ options: {
+ action: "/api/blade-resource/oss/endpoint/put-file",
+ props: {
+ res: "data",
+ url: "link",
+ },
+ },
+ minRows: 5,
+ span: 24,
+ },
+ {
+ label: "选择路径和标点",
+ labelWidth: "0",
+ prop: "line",
+ className: "mapClass",
+ hide: true,
+ display: true,
+ span: 24,
+ formslot: true,
+ addDisplay: true,
+ },
+ // {
+ // label: "路线",活动
+ // hide: true,
+ // prop: "lx",
+ // editDisply: false,
+ // addDisplay: false,
+ // },
+ ],
+ },
+ data: [],
+ LineData: [],
+ PointData: [],
+ }
},
- },
- methods: {
- setMapData(val) {
- this.LineData = val[0];
- this.PointData = val[1];
- },
- rowSave(row, done, loading) {
- var d = [];
- for (var k in row.tpurl) {
- d.push(row.tpurl[k].value);
- }
- row.tpurl = d.join(",");
- let outMapData = this.$refs.getMapData.myRulesUse();
- if (!outMapData) {
- loading();
- return;
- }
- row["lxname"] = outMapData[0][0];
- row["lx"] = outMapData[0][1];
- row["addressname"] = outMapData[1][0];
- row["address"] = outMapData[1][1];
- // console.log(row);
- // loading();
- // return;
- add(row).then(
- () => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- done();
+ // watch: {
+ // rotesData() {
+ // console.log(this.rotesData);
+ // },
+ // pointData() {
+ // console.log(this.pointData);
+ // },
+ // },
+ computed: {
+ ...mapGetters(["permission"]),
+ permissionList () {
+ return {
+ addBtn: this.vaildData(this.permission.hd_add, false),
+ viewBtn: this.vaildData(this.permission.hd_view, false),
+ delBtn: this.vaildData(this.permission.hd_delete, false),
+ editBtn: this.vaildData(this.permission.hd_edit, false),
+ }
},
- (error) => {
- loading();
- window.console.log(error);
- }
- );
- },
- rowUpdate(row, index, done, loading) {
- let outMapData = this.$refs.getMapData.myRulesUse();
- if (!outMapData) {
- loading();
- return;
- }
- row["lxname"] = outMapData[0][0];
- row["lx"] = outMapData[0][1];
- row["addressname"] = outMapData[1][0];
- row["address"] = outMapData[1][1];
- // console.log(row);
- // loading();
- // return;
- update(row).then(
- () => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- done();
+ ids () {
+ let ids = []
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id)
+ })
+ return ids.join(",")
},
- (error) => {
- loading();
- console.log(error);
- }
- );
},
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- });
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!",
- });
- this.$refs.crud.toggleSelection();
- });
- },
- checkDom(name, fn) {
- // 声明定时器
- let that = this;
- var timer = null;
+ methods: {
+ setMapData (val) {
+ this.LineData = val[0]
+ this.PointData = val[1]
+ },
+ rowSave (row, done, loading) {
+ var d = []
+ for (var k in row.tpurl) {
+ d.push(row.tpurl[k].value)
+ }
+ row.tpurl = d.join(",")
+ let outMapData = this.$refs.getMapData.myRulesUse()
+ if (!outMapData) {
+ loading()
+ return
+ }
+ row["lxname"] = outMapData[0][0]
+ row["lx"] = outMapData[0][1]
+ row["addressname"] = outMapData[1][0]
+ row["address"] = outMapData[1][1]
+ // console.log(row);
+ // loading();
+ // return;
+ add(row).then(
+ () => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ done()
+ },
+ (error) => {
+ loading()
+ window.console.log(error)
+ }
+ )
+ },
+ rowUpdate (row, index, done, loading) {
+ let outMapData = this.$refs.getMapData.myRulesUse()
+ if (!outMapData) {
+ loading()
+ return
+ }
+ row["lxname"] = outMapData[0][0]
+ row["lx"] = outMapData[0][1]
+ row["addressname"] = outMapData[1][0]
+ row["address"] = outMapData[1][1]
+ // console.log(row);
+ // loading();
+ // return;
+ update(row).then(
+ () => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ done()
+ },
+ (error) => {
+ loading()
+ console.log(error)
+ }
+ )
+ },
+ rowDel (row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(row.id)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ })
+ },
+ handleDelete () {
+ if (this.selectionList.length === 0) {
+ this.$message.warning("请选择至少一条数据")
+ return
+ }
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(this.ids)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ this.$refs.crud.toggleSelection()
+ })
+ },
+ checkDom (name, fn) {
+ // 声明定时器
+ let that = this
+ var timer = null
- // 检查dom是否执行完成
- function checkDom() {
- let dom = that.$refs[name];
- if (dom) {
- // 执行dom加载完成后的操作
- // 清除定时器
- if (!timer) {
- clearTimeout(timer);
- }
- if (fn) {
- //回调函数
- fn(dom);
- return;
- } else {
- return dom;
- }
- } else {
- // 自我调用
- timer = setTimeout(checkDom, 100);
- }
- }
+ // 检查dom是否执行完成
+ function checkDom () {
+ let dom = that.$refs[name]
+ if (dom) {
+ // 执行dom加载完成后的操作
+ // 清除定时器
+ if (!timer) {
+ clearTimeout(timer)
+ }
+ if (fn) {
+ //回调函数
+ fn(dom)
+ return
+ } else {
+ return dom
+ }
+ } else {
+ // 自我调用
+ timer = setTimeout(checkDom, 100)
+ }
+ }
- // 首次执行
- checkDom();
- },
- beforeOpen(done, type) {
- let that = this;
- if (["edit", "view"].includes(type)) {
- getDetail(this.form.id).then((res) => {
- this.form = res.data.data;
- });
- //控制按钮不可编辑
- this.checkDom("getMapData", (dom) => {
- // dom.init(val, num, value);
- dom[type + "Init"]([
- [that.form.lxname, that.form.lx],
- [that.form.addressname, that.form.address],
- ]);
- });
- }
+ // 首次执行
+ checkDom()
+ },
+ beforeOpen (done, type) {
+ let that = this
+ if (["edit", "view"].includes(type)) {
+ getDetail(this.form.id).then((res) => {
+ this.form = res.data.data
+ })
+ //控制按钮不可编辑
+ this.checkDom("getMapData", (dom) => {
+ // dom.init(val, num, value);
+ dom[type + "Init"]([
+ [that.form.lxname, that.form.lx],
+ [that.form.addressname, that.form.address],
+ ])
+ })
+ }
- done();
+ done()
+ },
+ searchReset () {
+ this.query = {}
+ this.onLoad(this.page)
+ },
+ searchChange (params, done) {
+ this.query = params
+ this.page.currentPage = 1
+ this.onLoad(this.page, params)
+ done()
+ },
+ selectionChange (list) {
+ this.selectionList = list
+ },
+ selectionClear () {
+ this.selectionList = []
+ this.$refs.crud.toggleSelection()
+ },
+ currentChange (currentPage) {
+ this.page.currentPage = currentPage
+ },
+ sizeChange (pageSize) {
+ this.page.pageSize = pageSize
+ },
+ refreshChange () {
+ this.onLoad(this.page, this.query)
+ },
+ onLoad (page, params = {}) {
+ this.loading = true
+ getList(
+ page.currentPage,
+ page.pageSize,
+ Object.assign(params, this.query)
+ ).then((res) => {
+ const data = res.data.data
+ this.page.total = data.total
+ this.data = data.records
+ this.loading = false
+ this.selectionClear()
+ })
+ },
},
- searchReset() {
- this.query = {};
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- getList(
- page.currentPage,
- page.pageSize,
- Object.assign(params, this.query)
- ).then((res) => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- },
- },
};
</script>
<style>
.mapClass {
- margin-left: 88px;
+ margin-left: 88px;
}
.mapClass div label {
- display: none;
+ display: none;
}
.mapClassMain {
- /* padding-left: 25px !important; */
+ /* padding-left: 25px !important; */
}
#getMapData {
- width: calc(100% + 90px);
- position: relative;
- left: -90px;
- height: 400px;
+ width: calc(100% + 90px);
+ position: relative;
+ left: -90px;
+ height: 400px;
}
</style>
--
Gitblit v1.9.3