Browse Source

时间管理等

dev-烟台中转登录
jiangyy 3 years ago
parent
commit
fc69eba815
  1. 14
      src/views/modules/communityParty/heart/heartForm.vue
  2. 560
      src/views/modules/cpts/base/cpts/edit.vue
  3. 148
      src/views/modules/shequzhili/event/cpts/add.vue

14
src/views/modules/communityParty/heart/heartForm.vue

@ -796,13 +796,13 @@ export default {
if (data.resultList && data.resultList.length > 0) { if (data.resultList && data.resultList.length > 0) {
this.resultListAct = data.resultList this.resultListAct = data.resultList
this.searchOptions = this.resultListAct.map(item => { this.searchOptionsAct = this.resultListAct.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` }; return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
}); });
} }
} else { } else {
this.searchOptions = [ this.searchOptionsAct = [
{ {
value: '0', value: '0',
label: '未检索到结果' label: '未检索到结果'
@ -810,7 +810,7 @@ export default {
] ]
} }
} else { } else {
this.searchOptions = []; this.searchOptionsAct = [];
} }
}, },
async remoteMethodSignin (query) { async remoteMethodSignin (query) {
@ -818,7 +818,7 @@ export default {
if (query !== '') { if (query !== '') {
this.loadingSign = true; this.loadingSign = true;
const { msg, data } = await map.searchNearby(query); const { msg, data } = await map_signin.searchNearby(query);
this.loadingSign = false; this.loadingSign = false;
this.resultListSignin = [] this.resultListSignin = []
@ -826,13 +826,13 @@ export default {
if (data.resultList && data.resultList.length > 0) { if (data.resultList && data.resultList.length > 0) {
this.resultListSignin = data.resultList this.resultListSignin = data.resultList
this.searchOptions = this.resultListSignin.map(item => { this.searchOptionsSignin = this.resultListSignin.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` }; return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
}); });
} }
} else { } else {
this.searchOptions = [ this.searchOptionsSignin = [
{ {
value: '0', value: '0',
label: '未检索到结果' label: '未检索到结果'
@ -840,7 +840,7 @@ export default {
] ]
} }
} else { } else {
this.searchOptions = []; this.searchOptionsSignin = [];
} }
}, },

560
src/views/modules/cpts/base/cpts/edit.vue

@ -1,327 +1,317 @@
<template> <template>
<div> <div>
<div class="dialog-h-content scroll-h"> <div class="dialog-h-content scroll-h">
<el-form <el-form v-if="iniLoaded"
v-if="iniLoaded" ref="ref_form"
ref="ref_form" :model="fmData"
:model="fmData" :inline="true"
:inline="true" :disabled="formType === 'watch'"
:disabled="formType === 'watch'" class="m-fm"
class="m-fm" :class="{ 'z-div': editParamsDiv, 'z-watch': formType === 'watch' }">
:class="{ 'z-div': editParamsDiv, 'z-watch': formType === 'watch' }"
>
<div class="list"> <div class="list">
<el-form-item <el-form-item v-for="item in editParams"
v-for="item in editParams" class="item"
class="item" label-width="140px"
label-width="140px" style="display: block"
style="display: block" :key="'edit' + item.keyName"
:key="'edit' + item.keyName" :label="item.field"
:label="item.field" :prop="item.keyName"
:prop="item.keyName" :rules="item.rules || []">
:rules="item.rules || []"
>
<template v-if="item.type == 'switch'"> <template v-if="item.type == 'switch'">
<el-switch <el-switch v-model="fmData[item.keyName]"
v-model="fmData[item.keyName]" size="small"
size="small" :active-text="item.activeText || ''"
:active-text="item.activeText || ''" :inactive-text="item.inactiveText || ''"
:inactive-text="item.inactiveText || ''" :active-value="item.activeValue || true"
:active-value="item.activeValue || true" :inactive-value="item.inactiveValue || false">
:inactive-value="item.inactiveValue || false"
>
</el-switch> </el-switch>
</template> </template>
<template v-if="item.type == 'input'"> <template v-if="item.type == 'input'">
<el-input <el-input v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
class="item-input" class="item-input"
size="small" size="small"
clearable clearable
show-word-limit show-word-limit
:maxlength="item.maxlength || ''" :maxlength="item.maxlength || ''"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'">
>
</el-input> </el-input>
<div class="item-show" v-else> <div class="item-show"
v-else>
{{ fmData[item.keyName] || "--" }} {{ fmData[item.keyName] || "--" }}
</div> </div>
</template> </template>
<template v-if="item.type == 'textarea'"> <template v-if="item.type == 'textarea'">
<el-input <el-input v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
type="textarea" type="textarea"
class="item-input" class="item-input"
size="small" size="small"
clearable clearable
show-word-limit show-word-limit
:rows="3" :rows="3"
:maxlength="item.maxlength || ''" :maxlength="item.maxlength || ''"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'">
>
</el-input> </el-input>
<div class="item-show" v-else> <div class="item-show"
v-else>
{{ fmData[item.keyName] || "--" }} {{ fmData[item.keyName] || "--" }}
</div> </div>
</template> </template>
<template v-if="item.type == 'date'"> <template v-if="item.type == 'date'">
<el-date-picker <el-date-picker v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
:picker-options="item.pickerOptions" :picker-options="item.pickerOptions"
class="item-input" class="item-input"
size="small" size="small"
clearable clearable
show-word-limit show-word-limit
:value-format="item.format || 'yyyy-MM-dd'" :value-format="item.format || 'yyyy-MM-dd'"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'">
>
</el-date-picker> </el-date-picker>
<div class="item-show" v-else> <div class="item-show"
v-else>
{{ fmData[item.keyName] || "--" }} {{ fmData[item.keyName] || "--" }}
</div> </div>
</template> </template>
<template v-if="item.type == 'number'"> <template v-if="item.type == 'number'">
<el-input-number <el-input-number v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
v-model="fmData[item.keyName]" v-model="fmData[item.keyName]"
class="item-number" class="item-number"
size="small" size="small"
clearable clearable
:precision="item.precision || 0" :precision="item.precision || 0"
:step="item.step || 1" :step="item.step || 1"
:min="item.min || 0" :min="item.min || 0"
:max="item.max || 999999999999" :max="item.max || 999999999999"
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'">
>
</el-input-number> </el-input-number>
<span class="item-show" v-else> <span class="item-show"
v-else>
{{ fmData[item.keyName] || "--" }} {{ fmData[item.keyName] || "--" }}
</span> </span>
<span v-if="item.unitName">{{ item.unitName }}</span> <span v-if="item.unitName">{{ item.unitName }}</span>
</template> </template>
<template v-else-if="item.type == 'select'"> <template v-else-if="item.type == 'select'">
<el-select <el-select v-model="fmData[item.keyName]"
v-model="fmData[item.keyName]" :placeholder="item.placeholder || '请选择'"
:placeholder="item.placeholder || '请选择'" size="small"
size="small" clearable
clearable class="item-select"
class="item-select" :multiple="item.multiple || false"
:multiple="item.multiple || false" :filterable="item.filterable || false"
:filterable="item.filterable || false" :allowCreate="item.allowCreate || false"
:allowCreate="item.allowCreate || false" :collapse-tags="item.collapseTags || false"
:collapse-tags="item.collapseTags || false" default-first-option
default-first-option @change="(e) => handleChangeSelect(e, item)">
@change="(e) => handleChangeSelect(e, item)"
>
<template v-if="item.optionType == 'group'"> <template v-if="item.optionType == 'group'">
<el-option-group <el-option-group v-for="group in item.optionList"
v-for="group in item.optionList" :key="group.label"
:key="group.label" :label="group.label">
:label="group.label" <el-option v-for="subItem in group.optionList"
> :key="subItem.value"
<el-option :label="subItem.label"
v-for="subItem in group.optionList" :value="subItem.value">
:key="subItem.value"
:label="subItem.label"
:value="subItem.value"
>
</el-option> </el-option>
</el-option-group> </el-option-group>
</template> </template>
<template v-else> <template v-else>
<el-option <el-option v-for="(subItem, subIndex) in item.optionList"
v-for="(subItem, subIndex) in item.optionList" :key="subItem.value + subIndex"
:key="subItem.value + subIndex" :label="subItem.label"
:label="subItem.label" :value="subItem.value">
:value="subItem.value"
>
</el-option> </el-option>
</template> </template>
</el-select> </el-select>
</template> </template>
<template v-else-if="item.type == 'rich-text'"> <template v-else-if="item.type == 'rich-text'">
<div <div v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
class="item-rich-text" class="item-rich-text">
> <Tinymce :ref="'richText' + item.keyName"
<Tinymce v-model="fmData[item.keyName]"
:ref="'richText' + item.keyName" :customerId="customerId"
v-model="fmData[item.keyName]" :placeholder="item.placeholder || '请输入'"
:customerId="customerId" :height="500" />
:placeholder="item.placeholder || '请输入'"
:height="500"
/>
</div> </div>
<div <div v-else
v-else class="item-rich-text z-show"
class="item-rich-text z-show" @click="handleClickHtmlNode">
@click="handleClickHtmlNode"
>
<div v-html="fmData[item.keyName]"></div> <div v-html="fmData[item.keyName]"></div>
</div> </div>
</template> </template>
<template v-else-if="item.type == 'cascader'"> <template v-else-if="item.type == 'cascader'">
<el-cascader <el-cascader v-model="fmData[item.keyName]"
v-model="fmData[item.keyName]" :placeholder="item.placeholder || '请选择'"
:placeholder="item.placeholder || '请选择'" :options="item.optionList"
:options="item.optionList" :props="item.optionProps || {}"
:props="item.optionProps || {}" :show-all-levels="false"
:show-all-levels="false" :collapse-tags="item.collapseTags || false"
:collapse-tags="item.collapseTags || false" size="small"
size="small" clearable
clearable class="item-select"
class="item-select" @change="(e) => handleChangeCascader(e, item)">
@change="(e) => handleChangeCascader(e, item)"
>
</el-cascader> </el-cascader>
</template> </template>
<template v-else-if="item.type == 'upload'"> <template v-else-if="item.type == 'upload'">
<el-upload <el-upload :headers="$getElUploadHeaders()"
:headers="$getElUploadHeaders()" v-if="
v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable) formType == 'add' || (formType == 'edit' && !item.editDisable)
" "
ref="upload" ref="upload"
class="avatar-uploader" class="avatar-uploader"
:class="{ 'z-full': fmData[item.keyName].length >= item.limit }" :class="{ 'z-full': fmData[item.keyName].length >= item.limit }"
:action="item.uploadUrl || uploadUrl" :action="item.uploadUrl || uploadUrl"
:data="{ customerId: customerId }" :data="{ customerId: customerId }"
:show-file-list="true" :show-file-list="true"
:list-type="item.listType || 'picture'" :list-type="item.listType || 'picture'"
:limit="item.limit || 100" :limit="item.limit || 100"
:file-list="fmData[item.keyName]" :file-list="fmData[item.keyName]"
:on-success="(res, file) => handleImgSuccess(res, file, item)" :on-success="(res, file) => handleImgSuccess(res, file, item)"
:on-error="(res, file) => handleImgError(res, file, item)" :on-error="(res, file) => handleImgError(res, file, item)"
:on-remove="(res) => handleImgRemove(res, item)" :on-remove="(res) => handleImgRemove(res, item)"
:on-exceed="(res) => handleImgExceed(res, item)" :on-exceed="(res) => handleImgExceed(res, item)"
:before-upload="(file) => beforeImgUpload(file, item)" :before-upload="(file) => beforeImgUpload(file, item)">
>
<a><i class="el-icon-plus"></i> 点击上传</a> <a><i class="el-icon-plus"></i> 点击上传</a>
</el-upload> </el-upload>
<el-image <el-image v-else-if="fmData[item.keyName].length > 0"
v-else-if="fmData[item.keyName].length > 0" style="width: 100px; height: 100px"
style="width: 100px; height: 100px" :src="fmData[item.keyName][0].url"
:src="fmData[item.keyName][0].url" fit="cover"
fit="cover" :preview-src-list="fmData[item.keyName].map((item) => item.url)"></el-image>
:preview-src-list="fmData[item.keyName].map((item) => item.url)"
></el-image>
<span v-else>--</span> <span v-else>--</span>
</template> </template>
<template v-else-if="item.type == 'address'"> <template v-else-if="item.type == 'address'">
<div class="address-item"> <div class="address-item">
<el-input <!-- <el-input class="address-item-input"
class="address-item-input" :placeholder="item.placeholder || '请输入所在地址'"
:placeholder="item.placeholder || '请输入所在地址'" v-model="fmData[item.keyName]"
v-model="fmData[item.keyName]" :maxlength="item.maxlength || ''"
:maxlength="item.maxlength || ''" show-word-limit
show-word-limit size="small">
size="small"
>
</el-input> </el-input>
<el-button <el-button style="margin-left: 10px"
style="margin-left: 10px" type="default"
type="default" size="small"
size="small" ref="mapSearch"
ref="mapSearch" @click="handleSearchMap(item)">查询</el-button> -->
@click="handleSearchMap(item)" <el-select v-model="searchValue"
>查询</el-button filterable
> class="item-input"
<div id="app" class="div_map"></div> remote
<div style="margin-top: 10px" v-show="false"> :reserve-keyword="true"
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading">
<el-option v-for="(item,index) in searchOptions"
@click.native="handleClickKey(index)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<div id="app_base"
class="div_map"></div>
<div style="margin-top: 10px"
v-show="false">
<span>经度</span> <span>经度</span>
<el-input <el-input class="address-item-input2"
class="address-item-input2" maxlength="50"
maxlength="50" placeholder="请输入经度"
placeholder="请输入经度" v-model="fmData[item.supKeys[0]]">
v-model="fmData[item.supKeys[0]]"
>
</el-input> </el-input>
<span style="margin-left: 20px">纬度</span> <span style="margin-left: 20px">纬度</span>
<el-input <el-input class="address-item-input2"
class="address-item-input2" maxlength="50"
maxlength="50" placeholder="请输入纬度"
placeholder="请输入纬度" v-model="fmData[item.supKeys[1]]">
v-model="fmData[item.supKeys[1]]"
>
</el-input> </el-input>
</div> </div>
</div> </div>
<el-input v-if="
formType == 'add' || (formType == 'edit' && !item.editDisable)
"
v-model="fmData[item.keyName]"
class="item-input"
size="small"
clearable
show-word-limit
:maxlength="item.maxlength || ''"
:placeholder="item.placeholder || '请输入'">
</el-input>
<div class="item-show"
v-else>
{{ fmData[item.keyName] || "--" }}
</div>
</template> </template>
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
<div class="div_btn resi-btns" v-if="!formBtnFixed"> <div class="div_btn resi-btns"
<el-button size="small" @click="handleCancle">{{ v-if="!formBtnFixed">
<el-button size="small"
@click="handleCancle">{{
editConfig.cancelBtnName || "取消" editConfig.cancelBtnName || "取消"
}}</el-button> }}</el-button>
<el-button <el-button v-if="formType != 'watch'"
v-if="formType != 'watch'" type="primary"
type="primary" size="small"
size="small" :disabled="btnDisable"
:disabled="btnDisable" @click="handleComfirm">{{ editConfig.confirmBtnName || "确定" }}</el-button>
@click="handleComfirm" <slot name="operateSup"
>{{ editConfig.confirmBtnName || "确定" }}</el-button v-bind:id="formId"
> v-bind:info="fmData"
<slot v-bind:formType="formType"></slot>
name="operateSup"
v-bind:id="formId"
v-bind:info="fmData"
v-bind:formType="formType"
></slot>
</div> </div>
<slot <slot name="bottomSup"
name="bottomSup" v-bind:id="formId"
v-bind:id="formId" v-bind:info="fmData"
v-bind:info="fmData" v-bind:formType="formType"></slot>
v-bind:formType="formType"
></slot>
</div> </div>
<div class="div_btn resi-btns" v-if="formBtnFixed"> <div class="div_btn resi-btns"
<el-button size="small" @click="handleCancle">{{ v-if="formBtnFixed">
<el-button size="small"
@click="handleCancle">{{
editConfig.cancelBtnName || "取消" editConfig.cancelBtnName || "取消"
}}</el-button> }}</el-button>
<el-button <el-button v-if="formType != 'watch'"
v-if="formType != 'watch'" type="primary"
type="primary" size="small"
size="small" :disabled="btnDisable"
:disabled="btnDisable" @click="handleComfirm">{{ editConfig.confirmBtnName || "确定" }}</el-button>
@click="handleComfirm" <slot name="operateSup"
>{{ editConfig.confirmBtnName || "确定" }}</el-button v-bind:id="formId"
> v-bind:info="fmData"
<slot v-bind:formType="formType"></slot>
name="operateSup"
v-bind:id="formId"
v-bind:info="fmData"
v-bind:formType="formType"
></slot>
</div> </div>
</div> </div>
</template> </template>
@ -394,10 +384,13 @@ export default {
}, },
}, },
data() { data () {
return { return {
iniLoaded: false, iniLoaded: false,
searchOptions: [],
searchValue: '',
resultList: [],
loading: false,
btnDisable: false, btnDisable: false,
fmData: {}, fmData: {},
@ -407,24 +400,26 @@ export default {
uploadUrl: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadqrcodeV2", uploadUrl: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadqrcodeV2",
customerId: localStorage.getItem("customerId"), customerId: localStorage.getItem("customerId"),
addressItem: {}
}; };
}, },
computed: {}, computed: {},
watch: { watch: {
editParams: { editParams: {
handler() { handler () {
this.computeFmData(); this.computeFmData();
}, },
deep: true, deep: true,
}, },
}, },
async mounted() { async mounted () {
this.initForm(); this.initForm();
}, },
methods: { methods: {
async initForm() { async initForm () {
this.iniFmData(); this.iniFmData();
if (this.formId && this.formType != "add") { if (this.formId && this.formType != "add") {
@ -432,11 +427,11 @@ export default {
} }
}, },
computeFmData() { computeFmData () {
console.log(this.fmData); console.log(this.fmData);
}, },
iniFmData() { iniFmData () {
const { editParams, fmData, editParamsDiv } = this; const { editParams, fmData, editParamsDiv } = this;
editParams.forEach((item, index) => { editParams.forEach((item, index) => {
if (typeof item.value == "function") { if (typeof item.value == "function") {
@ -491,6 +486,8 @@ export default {
} else if (item.type == "address") { } else if (item.type == "address") {
this.$nextTick(async () => { this.$nextTick(async () => {
await nextTick(300); await nextTick(300);
this.addressItem = item
this.initMap(item); this.initMap(item);
}); });
} }
@ -507,7 +504,7 @@ export default {
this.iniLoaded = true; this.iniLoaded = true;
}, },
handleClickHtmlNode(e) { handleClickHtmlNode (e) {
// //
if (e.target.localName.toLowerCase() === "a") { if (e.target.localName.toLowerCase() === "a") {
// //
@ -516,7 +513,7 @@ export default {
} }
}, },
async getFmOptions(index, url, params, cookFn) { async getFmOptions (index, url, params, cookFn) {
const { data, code, msg } = await requestPost(url, { const { data, code, msg } = await requestPost(url, {
...params, ...params,
}); });
@ -529,13 +526,13 @@ export default {
} }
}, },
handleChangeCascader(vals, item) { handleChangeCascader (vals, item) {
this.fmData[item["keyName"]] = vals; this.fmData[item["keyName"]] = vals;
if (typeof item.handleChangeFn == "function") { if (typeof item.handleChangeFn == "function") {
item.handleChangeFn(vals, item, this); item.handleChangeFn(vals, item, this);
} }
}, },
handleChangeSelect(vals, item) { handleChangeSelect (vals, item) {
console.log(vals, item); console.log(vals, item);
this.fmData[item["keyName"]] = vals; this.fmData[item["keyName"]] = vals;
if (typeof item.handleChangeFn == "function") { if (typeof item.handleChangeFn == "function") {
@ -543,14 +540,14 @@ export default {
} }
}, },
beforeImgUpload(file, item) { beforeImgUpload (file, item) {
if (typeof item.beforeImgUpload == "function") { if (typeof item.beforeImgUpload == "function") {
if (!item.beforeImgUpload(file, item, this)) return false; if (!item.beforeImgUpload(file, item, this)) return false;
} }
return true; return true;
}, },
handleImgRemove(file, item) { handleImgRemove (file, item) {
console.log("handleImgRemove", file); console.log("handleImgRemove", file);
let url = file.response ? file.response.data.url : file.url; let url = file.response ? file.response.data.url : file.url;
if (url) { if (url) {
@ -572,7 +569,7 @@ export default {
} }
}, },
handleImgExceed(res, item) { handleImgExceed (res, item) {
console.log(res); console.log(res);
// this.$message({ // this.$message({
// type: "warning", // type: "warning",
@ -580,7 +577,7 @@ export default {
// }); // });
}, },
handleImgSuccess(res, file, item) { handleImgSuccess (res, file, item) {
console.log("handleImgSuccess", res); console.log("handleImgSuccess", res);
if (res.code === 0 && res.msg === "success") { if (res.code === 0 && res.msg === "success") {
let { fmData } = this; let { fmData } = this;
@ -616,16 +613,16 @@ export default {
} }
}, },
handleImgError(res, file, item) { handleImgError (res, file, item) {
console.log(res); console.log(res);
}, },
// init // init
initMap(item) { initMap (item) {
let { latitude, longitude } = this.$store.state.user; let { latitude, longitude } = this.$store.state.user;
map = new daiMap( map = new daiMap(
document.getElementById("app"), document.getElementById("app_base"),
{ latitude, longitude }, { latitude, longitude },
{ {
zoom: 16.2, // zoom: 16.2, //
@ -638,10 +635,13 @@ export default {
map.on("dragend", (e) => { map.on("dragend", (e) => {
this.handleMoveCenter(item, e); this.handleMoveCenter(item, e);
}); });
// this.handleMoveCenter(item); map.setCenter(latitude, longitude);
map.setMarker(latitude, longitude);
}, },
async handleSearchMap(item) {
async handleSearchMap (item) {
const { msg, data } = await map.searchNearby(this.fmData[item.keyName]); const { msg, data } = await map.searchNearby(this.fmData[item.keyName]);
if (msg == "success") { if (msg == "success") {
const { lat, lng } = data; const { lat, lng } = data;
@ -654,7 +654,7 @@ export default {
} }
}, },
async handleMoveCenter(item, e) { async handleMoveCenter (item, e) {
console.log("handleMoveCenter", e); console.log("handleMoveCenter", e);
// //
const { lat, lng } = map.getCenter(); const { lat, lng } = map.getCenter();
@ -666,10 +666,60 @@ export default {
let { msg, data } = await map.getAddress(lat, lng); let { msg, data } = await map.getAddress(lat, lng);
if (msg == "success") { if (msg == "success") {
this.fmData[item.keyName] = data.address; this.fmData[item.keyName] = data.address;
this.searchValue = data.address
this.searchOptions = []
} }
}, },
async getInfo() { async remoteMethod (query) {
if (query !== '') {
this.loading = true;
const { msg, data } = await map.searchNearby(query);
this.loading = false;
this.resultList = []
if (msg == "success" && data.resultList && data.resultList.length > 0) {
if (data.resultList && data.resultList.length > 0) {
this.resultList = data.resultList
this.searchOptions = this.resultList.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
});
}
} else {
this.searchOptions = [
{
value: '0',
label: '未检索到结果'
}
]
}
} else {
this.searchOptions = [];
}
},
handleClickKey (index) {
let selPosition = this.resultList[index]
let lonlat = selPosition.lonlat.split(" ")
map.setCenter(lonlat[1], lonlat[0]);
map.setMarker(lonlat[1], lonlat[0]);
this.fmData[this.addressItem.supKeys[0]] = lonlat[1];
this.fmData[this.addressItem.supKeys[1]] = lonlat[0];
// this.formData.latitude = lonlat[1];
// this.formData.longitude = lonlat[0];
// this.formData.address = selPosition.address + selPosition.name
this.fmData[this.addressItem.keyName] = selPosition.address + selPosition.name
},
async getInfo () {
let url = this.infoUrl; let url = this.infoUrl;
if (!url) return; if (!url) return;
const { idName, formId } = this; const { idName, formId } = this;
@ -710,12 +760,12 @@ export default {
} }
}, },
watchImg(src) { watchImg (src) {
window.open(src); window.open(src);
}, },
// //
dormatHtml(content) { dormatHtml (content) {
if ( if (
content.startsWith( content.startsWith(
"<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n" "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n"
@ -727,7 +777,7 @@ export default {
return content; return content;
}, },
cookBeforeSubmit(data) { cookBeforeSubmit (data) {
Object.keys(data).forEach((k) => { Object.keys(data).forEach((k) => {
if (typeof data[k] == "string") { if (typeof data[k] == "string") {
data[k] = this.dormatHtml(data[k]); data[k] = this.dormatHtml(data[k]);
@ -736,7 +786,7 @@ export default {
return data; return data;
}, },
async handleComfirm() { async handleComfirm () {
this.btnDisable = true; this.btnDisable = true;
setTimeout(() => { setTimeout(() => {
this.btnDisable = false; this.btnDisable = false;
@ -768,7 +818,7 @@ export default {
}); });
}, },
async submit() { async submit () {
const { editConfig, fmData, formType, editFixedParams } = this; const { editConfig, fmData, formType, editFixedParams } = this;
if ( if (
typeof editConfig.beforeSubmit == "function" && typeof editConfig.beforeSubmit == "function" &&
@ -808,7 +858,7 @@ export default {
} }
}, },
handleCancle() { handleCancle () {
this.$emit("close"); this.$emit("close");
}, },
}, },

148
src/views/modules/shequzhili/event/cpts/add.vue

@ -130,50 +130,39 @@
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="地理位置" <el-form-item label="地图位置"
prop="address"
label-width="150px"
style="display: block">
<el-input class="cell-width-1"
v-model="formData.address">
</el-input>
</el-form-item>
<el-form-item label="位置坐标"
prop="longitude" prop="longitude"
label-width="150px" label-width="150px"
style="display: block"> style="display: block">
<div style="width: 500px"> <div style="width: 500px">
<el-input class="item_width_4" <el-select v-model="searchValue"
maxlength="50" filterable
placeholder="请输入关键字" style="width: 500px"
v-model="formData.address"> remote
</el-input> :reserve-keyword="true"
<el-button style="margin-left: 10px" placeholder="请输入关键词"
type="default" :remote-method="remoteMethod"
size="small" :loading="loading">
@click="handleSearchMap">查询</el-button> <el-option v-for="(item,index) in searchOptions"
<div id="map_event" @click.native="handleClickKey(index)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<div id="app_event"
class="div_map"></div> class="div_map"></div>
<!-- <div style="margin-top: 10px" v-show="false">
<span>经度</span>
<el-input
class="item_width_3"
maxlength="50"
placeholder="请输入经度"
v-model="formData.longitude"
>
</el-input>
<span style="margin-left: 20px">纬度</span>
<el-input
class="item_width_3"
maxlength="50"
placeholder="请输入纬度"
v-model="formData.latitude"
>
</el-input>
</div> -->
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="详细地址"
prop="address"
label-width="150px"
style="display: block">
<el-input class="cell-width-1"
v-model="formData.address">
</el-input>
</el-form-item>
</el-form> </el-form>
</div> </div>
</div> </div>
@ -249,6 +238,7 @@ var geocoder; // 新建一个正逆地址解析类
function iniFmData () { function iniFmData () {
return { return {
gridId: "", // gridId: "", //
reportUserId: "", // ID reportUserId: "", // ID
name: "", // name: "", //
@ -272,6 +262,10 @@ export default {
data () { data () {
return { return {
formType: "add", // addeditdetail formType: "add", // addeditdetail
searchOptions: [],
searchValue: '',
resultList: [],
loading: false,
btnDisable: false, btnDisable: false,
gridList: [], //list-- gridList: [], //list--
@ -397,10 +391,9 @@ export default {
this.formData.latitude = latitude; this.formData.latitude = latitude;
this.formData.longitude = longitude; this.formData.longitude = longitude;
this.initMap();
map.setCenter(this.formData.latitude, this.formData.longitude); this.initMap(this.formData.latitude, this.formData.longitude);
map.setMarker(this.formData.latitude, this.formData.longitude);
this.handleMoveCenter()
this.loadGrid(); this.loadGrid();
this.getCategoryList(); this.getCategoryList();
@ -570,11 +563,10 @@ export default {
}, },
// init // init
initMap () { initMap (latitude, longitude) {
let { latitude, longitude } = this.$store.state.user;
map = new daiMap( map = new daiMap(
document.getElementById("map_event"), document.getElementById("app_event"),
{ latitude, longitude }, { latitude, longitude },
{ {
zoom: 16.2, // zoom: 16.2, //
@ -587,21 +579,14 @@ export default {
map.on("dragend", (e) => { map.on("dragend", (e) => {
this.handleMoveCenter(e); this.handleMoveCenter(e);
}); });
},
async handleSearchMap () { map.setCenter(latitude, longitude);
const { msg, data } = await map.searchNearby(this.formData.address); map.setMarker(latitude, longitude);
if (msg == "success") {
const { lat, lng } = data;
map.setCenter(lat, lng);
map.setMarker(lat, lng);
this.formData.latitude = lat;
this.formData.longitude = lng;
} else {
this.$message.error("未检索到相关位置坐标");
}
}, },
async handleMoveCenter (e) {
async handleMoveCenter () {
// //
const { lat, lng } = map.getCenter(); const { lat, lng } = map.getCenter();
this.formData.latitude = lat; this.formData.latitude = lat;
@ -610,13 +595,60 @@ export default {
let { msg, data } = await map.getAddress(lat, lng); let { msg, data } = await map.getAddress(lat, lng);
if (msg == "success") { if (msg == "success") {
this.formData.address = data.address; this.formData.address = data.address
this.searchValue = data.address
this.searchOptions = []
}
},
async remoteMethod (query) {
if (query !== '') {
this.loading = true;
const { msg, data } = await map.searchNearby(query);
this.loading = false;
this.resultList = []
if (msg == "success" && data.resultList && data.resultList.length > 0) {
if (data.resultList && data.resultList.length > 0) {
this.resultList = data.resultList
this.searchOptions = this.resultList.map(item => {
return { value: `${item.hotPointID}`, label: `${item.address + item.name}` };
});
}
} else {
this.searchOptions = [
{
value: '0',
label: '未检索到结果'
}
]
}
} else {
this.searchOptions = [];
} }
}, },
handleClickKey (index) {
let selPosition = this.resultList[index]
let lonlat = selPosition.lonlat.split(" ")
map.setCenter(lonlat[1], lonlat[0]);
map.setMarker(lonlat[1], lonlat[0]);
this.formData.latitude = lonlat[1];
this.formData.longitude = lonlat[0];
this.formData.address = selPosition.address + selPosition.name
},
resetData () { resetData () {
this.formData = iniFmData(); this.formData = iniFmData();
this.replayImgList = []; this.replayImgList = [];
this.searchValue = ''
this.searchOptions = []
this.resultList = []
}, },
// //
startLoading () { startLoading () {

Loading…
Cancel
Save