You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1051 lines
31 KiB
1051 lines
31 KiB
<template>
|
|
<div>
|
|
<div class="dialog-h-content scroll-h">
|
|
<el-form
|
|
ref="ref_form"
|
|
:inline="true"
|
|
:model="formData"
|
|
:rules="dataRule"
|
|
:disabled="formType === 'detail'"
|
|
class="div_form"
|
|
>
|
|
<!-- 政策类型 -->
|
|
<el-form-item label="政策类型" prop="categoryCode" label-width="150px">
|
|
<el-cascader
|
|
ref="categoryCode"
|
|
v-model="formData.categoryCode"
|
|
:options="demandOptions"
|
|
:props="{label: 'categoryName',value: 'categoryCode',children: 'childCateList'}"
|
|
clearable
|
|
size="small"
|
|
class="u-item-width-normal"
|
|
@change="handelChangeCategoryCode"
|
|
></el-cascader>
|
|
</el-form-item>
|
|
<el-form-item
|
|
label="政策标题"
|
|
prop="title"
|
|
label-width="150px"
|
|
style="display: block"
|
|
>
|
|
<el-input
|
|
class="item_width_1"
|
|
placeholder="请输入政策标题"
|
|
v-model="formData.title"
|
|
>
|
|
</el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
label="政策有效期"
|
|
style="display: block"
|
|
label-width="150px"
|
|
prop="startDate"
|
|
>
|
|
<el-date-picker
|
|
v-model="formData.startDate"
|
|
class="item_width_2"
|
|
type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value="yyyy-MM-dd HH:mm:ss"
|
|
placeholder="开始时间"
|
|
>
|
|
</el-date-picker>
|
|
<span class="u-data-tag">至</span>
|
|
<el-date-picker
|
|
v-model="formData.endDate"
|
|
class="item_width_2 u-data-tag"
|
|
type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value="yyyy-MM-dd HH:mm:ss"
|
|
placeholder="结束时间"
|
|
>
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
label="政策级别"
|
|
style="display: block"
|
|
label-width="150px"
|
|
prop="policyLevel"
|
|
>
|
|
<el-select
|
|
class="item_width_2"
|
|
v-model="formData.policyLevel"
|
|
placeholder="全部"
|
|
clearable
|
|
>
|
|
<el-option
|
|
v-for="item in policyLevelArray"
|
|
:key="item.value"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
label="政策内容"
|
|
prop="content"
|
|
label-width="150px"
|
|
style="display: block"
|
|
>
|
|
<el-input
|
|
class="item_width_3"
|
|
type="textarea"
|
|
maxlength="1000"
|
|
show-word-limit
|
|
:rows="10"
|
|
placeholder="请输入政策内容"
|
|
v-model="formData.content"
|
|
></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
style="display: block"
|
|
label="附件"
|
|
label-width="150px"
|
|
prop="attach"
|
|
>
|
|
<el-upload
|
|
:headers="$getElUploadHeaders()"
|
|
class="upload-demo"
|
|
:action="uploadUlr"
|
|
accept=".doc,.pdf,.xls,.docx,.xlsx,.jpg,.png,.jpeg,.bmp,.mp4,.wma,.m4a,.mp3"
|
|
:on-success="handleFileSuccess"
|
|
:on-remove="handleFileRemove"
|
|
:on-preview="handleFileDownload"
|
|
:limit="3"
|
|
:before-upload="beforeUpload"
|
|
:file-list="fileList"
|
|
>
|
|
<el-button
|
|
size="small"
|
|
:disabled="fileList.length === 3"
|
|
type="primary"
|
|
>点击上传</el-button
|
|
>
|
|
<div slot="tip" class="el-upload__tip">支持图片、word、pdf</div>
|
|
</el-upload>
|
|
</el-form-item>
|
|
<el-form-item
|
|
label="查找符合政策人员"
|
|
prop="resiSearchTagId"
|
|
label-width="150px"
|
|
:required="true"
|
|
style="display: block"
|
|
>
|
|
<template v-if="formData.resiSearchTagName">
|
|
<el-tag
|
|
@close="handleCloseTag"
|
|
:closable="formType != 'detail'"
|
|
style="margin-right: 10px"
|
|
>
|
|
{{ formData.resiSearchTagName }}
|
|
</el-tag>
|
|
</template>
|
|
|
|
<el-button type="primary" @click="handleClickLabel" size="mini">
|
|
<span> <i class="el-icon-plus"></i> 按标签查找 </span>
|
|
</el-button>
|
|
</el-form-item>
|
|
<el-form-item label="指派服务" label-width="150px">
|
|
<el-switch
|
|
:active-value="1"
|
|
:inactive-value="0"
|
|
v-model="formData.assignFlag"
|
|
>
|
|
</el-switch>
|
|
</el-form-item>
|
|
</el-form>
|
|
<el-form
|
|
:model="newFormData"
|
|
:disabled="formType === 'detail'"
|
|
:rules="newDataRule"
|
|
ref="ref_policy_form1"
|
|
v-if="newFormData"
|
|
>
|
|
<!-- 使用v-if后动态显示隐藏方法失效 -->
|
|
<el-form-item
|
|
v-if="formData.assignFlag"
|
|
label="服务组织"
|
|
label-width="150px"
|
|
style="display: block"
|
|
prop="serverOrgId"
|
|
>
|
|
<el-select
|
|
v-model="newFormData.serverOrgType"
|
|
class="input-width-small"
|
|
placeholder="请选择"
|
|
clearable
|
|
@change="handleServiceChange('add', $event)"
|
|
>
|
|
<el-option
|
|
v-for="item in serviceOptions"
|
|
:key="item.value"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
-
|
|
<el-select
|
|
v-model="newFormData.serverOrgId"
|
|
class="input-width-middle"
|
|
filterable
|
|
placeholder="请选择"
|
|
clearable
|
|
>
|
|
<el-option
|
|
v-for="item in serviceOptiondList"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item
|
|
v-if="formData.assignFlag"
|
|
prop="noticeApproches"
|
|
label="自动通知服务组织"
|
|
label-width="150px"
|
|
style="display: block"
|
|
>
|
|
<el-checkbox-group v-model="newFormData.noticeApproches">
|
|
<el-checkbox label="sms" value="sms">短信通知</el-checkbox>
|
|
<el-checkbox label="wx" value="wx">微信公众号消息通知</el-checkbox>
|
|
</el-checkbox-group>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
v-if="formData.assignFlag"
|
|
label="服务范围"
|
|
label-width="150px"
|
|
style="display: block"
|
|
prop="serviceScopeList"
|
|
>
|
|
<el-cascader
|
|
class="item_width_1"
|
|
ref="myCascader"
|
|
v-model="newFormData.serviceScopeList"
|
|
:key="iscascaderShow"
|
|
:options="casOptions"
|
|
:props="optionProps"
|
|
:show-all-levels="false"
|
|
></el-cascader>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
v-if="formData.assignFlag"
|
|
label="服务时间"
|
|
label-width="150px"
|
|
prop="serviceTimeEnd"
|
|
>
|
|
<!-- :picker-options="startPickerOptions" -->
|
|
<el-date-picker
|
|
v-model="newFormData.serviceTimeStart"
|
|
class="item_width_2"
|
|
style="width: 220px"
|
|
type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value="yyyy-MM-dd HH:mm:ss"
|
|
placeholder="开始时间"
|
|
>
|
|
</el-date-picker>
|
|
<!-- :picker-options="endPickerOptions" -->
|
|
<span class="u-data-tag">至</span>
|
|
<el-date-picker
|
|
v-model="newFormData.serviceTimeEnd"
|
|
class="item_width_2 u-data-tag"
|
|
style="width: 220px"
|
|
type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value="yyyy-MM-dd HH:mm:ss"
|
|
placeholder="结束时间"
|
|
>
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
|
|
<div class="div_btn">
|
|
<el-button size="small" @click="handleCancle">取 消</el-button>
|
|
<el-button
|
|
v-if="formType !== 'detail'"
|
|
size="small"
|
|
type="primary"
|
|
:disabled="btnDisable"
|
|
@click="handleAdd"
|
|
>确 定</el-button
|
|
>
|
|
</div>
|
|
<el-dialog
|
|
v-if="showLabelForm"
|
|
:visible.sync="showLabelForm"
|
|
:append-to-body="true"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:title="'标签配置'"
|
|
width="954px"
|
|
top="5vh"
|
|
class="dialog-h"
|
|
@closed="showLabelForm = false"
|
|
>
|
|
<label-form
|
|
ref="ref_label_form"
|
|
@dialogCancle="addFormCancle"
|
|
@dialogOk="addFormOk"
|
|
>
|
|
</label-form>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters } from "vuex";
|
|
import { Loading } from "element-ui"; // 引入Loading服务
|
|
import { requestPost, requestGet } from "@/js/dai/request";
|
|
import rule from "./rule";
|
|
import labelForm from "../labelConfig/addForm.vue";
|
|
|
|
let loading; // 加载动画
|
|
export default {
|
|
data() {
|
|
let endDisabledDate = (time) => {
|
|
//这个关键属性我们一定要写在data的里面并且return的外面,这是动态改变区间的关键
|
|
let nowData = Date.now();
|
|
if (this.formData.serviceTimeStart) {
|
|
let serviceTimeStart = new Date(this.formData.serviceTimeStart);
|
|
return (
|
|
time.getTime() > nowData ||
|
|
time.getTime() < serviceTimeStart ||
|
|
time.getTime() === serviceTimeStart
|
|
);
|
|
} else {
|
|
return time.getTime() > nowData;
|
|
}
|
|
};
|
|
let startDisabledDate = (time) => {
|
|
//这个关键属性我们一定要写在data的里面并且return的外面,这是动态改变区间的关键
|
|
let nowData = Date.now();
|
|
return time.getTime() > nowData;
|
|
};
|
|
|
|
return {
|
|
// ruleList: [
|
|
// {
|
|
// ruleName: '',
|
|
// resiRuleList: [],
|
|
// houseRuleList: [],
|
|
// statRuleList: []
|
|
// }
|
|
// ],
|
|
|
|
policyLevelArray: [],
|
|
// 公共服务分类
|
|
|
|
iscascaderShow: 0,
|
|
|
|
btnDisable: false,
|
|
demandOptions: [],
|
|
demandIdArray: [],
|
|
|
|
optionProps: {
|
|
multiple: true,
|
|
value: "objectId",
|
|
label: "objectName",
|
|
children: "children",
|
|
checkStrictly: true,
|
|
emitPath: false,
|
|
},
|
|
|
|
formData: {
|
|
categoryCode: [],
|
|
parentCategoryCode: "",
|
|
policyLevel: "", //政府级别
|
|
startDate: "", //起始时间yyyy-MM-dd
|
|
endDate: "", //截止时间yyyy-MM-dd
|
|
title: "", //
|
|
content: "", //
|
|
attachmentList: [],
|
|
resiSearchTagName: "", //符合政策人员标签
|
|
assignFlag: 0, //是否指派服务
|
|
resiSearchTagId: "", //符合政策人员id
|
|
assignInfo: {},
|
|
|
|
// ruleList: [
|
|
// {
|
|
// ruleName: '',
|
|
// resiRuleList: [],
|
|
// houseRuleList: [],
|
|
// statRuleList: []
|
|
// }
|
|
// ],
|
|
},
|
|
serviceOptiondList: "",
|
|
newFormData: {
|
|
noticeApproches: [],
|
|
serviceScopeList: [], //
|
|
serviceTimeStart: "", //服务起始时间yyyy-MM-dd
|
|
serviceTimeEnd: "", //服务截止时间yyyy-MM-dd
|
|
serverOrgType: "", //服务组织类型 社区自组织:community_org, 志愿者:ic_user_volunteer, 联建单位:party_unit
|
|
serverOrgId: "", //服务组织Id
|
|
},
|
|
newDataRule: {
|
|
serverOrgId: [
|
|
{ required: true, message: "服务组织不能为空", trigger: "bulr" },
|
|
],
|
|
serviceScopeList: [
|
|
{ required: true, message: "服务范围不能为空", trigger: "bulr" },
|
|
],
|
|
serviceTimeEnd: [
|
|
{ required: true, message: "服务时间不能为空", trigger: "bulr" },
|
|
],
|
|
},
|
|
endPickerOptions: {
|
|
disabledDate: endDisabledDate,
|
|
},
|
|
startPickerOptions: {
|
|
disabledDate: startDisabledDate,
|
|
},
|
|
|
|
fileList: [],
|
|
uploadUlr: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadvariedfile",
|
|
showLabelForm: false, //标签组件状态
|
|
|
|
newArr: [],
|
|
sarr: [],
|
|
casOptions: [],
|
|
|
|
serviceOptions:[],
|
|
originalServiceOptions:[]
|
|
};
|
|
},
|
|
|
|
watch: {
|
|
"formData.serviceTimeEnd": function (val) {
|
|
if (val && val != "") {
|
|
let arrayTemp = val.split(" ");
|
|
this.formData.serviceTimeEnd = arrayTemp[0] + " 23:59:59";
|
|
}
|
|
},
|
|
},
|
|
components: { rule, labelForm },
|
|
async mounted() {
|
|
await this.startLoading();
|
|
await this.getServiceTypeDictOptions();
|
|
await this.getDictOptions();
|
|
await this.loadScopeTree();
|
|
await this.getDemandOptions();
|
|
if (this.formType === "add") {
|
|
this.$refs.ref_form.resetFields();
|
|
} else {
|
|
await this.loadFormInfo();
|
|
await this.getServiceuserList();
|
|
}
|
|
|
|
this.endLoading();
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 获取服务范围树
|
|
async loadScopeTree() {
|
|
const url = "/gov/org/icServiceProject/service/serviceScopeTree";
|
|
// const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/isServiceProject/service/serviceScopeTree'
|
|
let params = {};
|
|
|
|
const { data, code, msg } = await requestPost(url, params);
|
|
|
|
if (code === 0) {
|
|
++this.iscascaderShow;
|
|
this.casOptions = [];
|
|
this.scopeIdArray = [];
|
|
this.casOptions.push(data);
|
|
} else {
|
|
this.$message.error(rspMsg);
|
|
}
|
|
},
|
|
|
|
async loadFormInfo() {
|
|
const url = "/governance/policy/policyDetail/" + this.policyId;
|
|
|
|
let params = {};
|
|
|
|
const { data, code, msg } = await requestGet(url, params);
|
|
|
|
if (code === 0) {
|
|
this.demandIdArray = [];
|
|
// data.categoryList.forEach((element) => {
|
|
// let arr = element.codePath.split(",");
|
|
// this.demandIdArray.push(arr);
|
|
// });
|
|
// this.formData.ruleList = data.ruleList
|
|
data.policyLevel = "" + data.policyLevel;
|
|
this.formData = data;
|
|
if (data.categoryCode) {
|
|
this.formData.categoryCode = [data.parentCategoryCode, data.categoryCode];
|
|
} else {
|
|
this.formData.categoryCode = [data.parentCategoryCode];
|
|
}
|
|
this.newFormData = data.assignInfo;
|
|
if (data.assignInfo) {
|
|
for (let i in data.assignInfo.serviceScopeList) {
|
|
this.newFormData.serviceScopeList.push(
|
|
data.assignInfo.serviceScopeList[i].objectId
|
|
);
|
|
}
|
|
if(data.assignInfo.noticeApproches==null){
|
|
data.assignInfo.noticeApproches = []
|
|
}
|
|
} else {
|
|
this.newFormData = {
|
|
noticeApproches: [],
|
|
serviceScopeList: [], //
|
|
serviceTimeStart: "", //服务起始时间yyyy-MM-dd
|
|
serviceTimeEnd: "", //服务截止时间yyyy-MM-dd
|
|
serverOrgType: "", //服务组织类型 社区自组织:community_org, 志愿者:ic_user_volunteer, 联建单位:party_unit
|
|
serverOrgId: "", //服务组织Id
|
|
};
|
|
}
|
|
if (data.attachmentList) {
|
|
this.fileList = data.attachmentList;
|
|
}
|
|
|
|
// this.$nextTick(() => {
|
|
// data.ruleList.forEach((element, index) => {
|
|
|
|
// this.$refs['ref_rule' + index][0].setRule(element.resiRuleList, element.houseRuleList, element.statRuleList)
|
|
// });
|
|
// })
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
handelChangeCategoryCode() {
|
|
this.serviceOptions = [...this.originalServiceOptions];
|
|
const parentMappings = {
|
|
'公益事业类': ['party_unit', 'community_org'],
|
|
'技能培训类': ['party_unit', 'community_org', 'publicWelfare'],
|
|
'教育讲座类': ['party_unit', 'community_org'],
|
|
'社会治理类': ['party_unit', 'community_org'],
|
|
'公共服务类': ['party_unit', 'community_org', 'publicWelfare'],
|
|
'设施维护类': ['party_unit', 'community_org', 'publicWelfare'],
|
|
'岗位提供类': ['party_unit', 'community_org'],
|
|
};
|
|
const checkedParent = this.$refs['categoryCode'].getCheckedNodes()[0].parent.label;
|
|
if (parentMappings[checkedParent] && Array.isArray(parentMappings[checkedParent])) {
|
|
this.serviceOptions = this.serviceOptions.filter(item => parentMappings[checkedParent].includes(item.value));
|
|
} else {
|
|
this.serviceOptions = this.originalServiceOptions
|
|
}
|
|
console.log(this.serviceOptions);
|
|
},
|
|
//点击标签触发事件
|
|
handleClickLabel() {
|
|
this.showLabelForm = true;
|
|
this.$refs['ref_form'].clearValidate('resiSearchTagId')
|
|
this.$nextTick(() => {
|
|
this.$refs["ref_label_form"].initForm("info");
|
|
});
|
|
},
|
|
addFormOk(val) {
|
|
this.showLabelForm = false;
|
|
this.formData.resiSearchTagId = val.tagId;
|
|
this.formData.resiSearchTagName = val.tagName;
|
|
},
|
|
addFormCancle() {
|
|
this.showLabelForm = false;
|
|
},
|
|
handleCloseTag() {
|
|
this.formData.resiSearchTagId = "";
|
|
this.formData.resiSearchTagName = "";
|
|
},
|
|
//获取标签名称并过滤
|
|
async getTagName() {
|
|
const url = "/governance/resiSearchTag/listResiSearchTags";
|
|
let params = {
|
|
pageSize: 99,
|
|
};
|
|
let { data, msg, code } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
let showAddProduct = data.list.filter((item) => {
|
|
return [this.formData.resiSearchTagId].includes(item.tagId);
|
|
});
|
|
if (this.formData.resiSearchTagId) {
|
|
this.formData.resiSearchTagName = showAddProduct[0].tagName;
|
|
} else {
|
|
this.formData.resiSearchTagName = "--";
|
|
}
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
async handleServiceChange() {
|
|
this.newFormData.serverOrgId = ''
|
|
await this.getServiceuserList();
|
|
},
|
|
async getServiceuserList() {
|
|
if (!this.formData.assignFlag) return;
|
|
if (this.formData.categoryCode.length==0) {
|
|
this.$message.error("请先选择政策类型!");
|
|
return;
|
|
}
|
|
const url = "/actual/base/serviceitem/listServerOrgNewTask";
|
|
let params = {
|
|
serverOrgCategoryCode: this.formData.categoryCode[1],
|
|
serverParentOrgCategoryCode:this.formData.categoryCode[0],
|
|
serverOrgType: this.newFormData.serverOrgType ||this.formData.assignInfo.serverOrgType,
|
|
};
|
|
console.log(this.formData);
|
|
let { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.serviceOptiondList = data;
|
|
} else if (code >= 8000) {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
async getServiceTypeDictOptions() {
|
|
this.$http
|
|
.post("/sys/dict/data/dictlist", {
|
|
dictType: "user_demand_service_type",
|
|
})
|
|
.then(({ data: res }) => {
|
|
if (res.code !== 0) {
|
|
return this.$message.error(res.msg);
|
|
} else {
|
|
this.serviceOptions = res.data;
|
|
this.originalServiceOptions = [...this.serviceOptions];
|
|
|
|
}
|
|
})
|
|
.catch(() => {
|
|
console.log("组织类型获取失败!");
|
|
});
|
|
},
|
|
getDictOptions() {
|
|
this.$http
|
|
.post("/sys/dict/data/dictlist", {
|
|
dictType: "policy_level",
|
|
})
|
|
.then(({ data: res }) => {
|
|
if (res.code !== 0) {
|
|
return this.$message.error(res.msg);
|
|
} else {
|
|
this.policyLevelArray = res.data;
|
|
}
|
|
})
|
|
.catch(() => {
|
|
return this.$message.error("网络错误");
|
|
});
|
|
|
|
|
|
},
|
|
|
|
async handleAdd() {
|
|
// var oDate1 = new Date(this.formData.startDate);
|
|
// var oDate2 = new Date(this.formData.endDate);
|
|
// if (oDate1.getTime() > oDate2.getTime()) {
|
|
// this.$message.error("结束日期必须大于开始日期");
|
|
// return false;
|
|
// }
|
|
|
|
// // this.formData.ruleList = this.ruleList
|
|
|
|
// // return false
|
|
// this.btnDisable = true;
|
|
// setTimeout(() => {
|
|
// this.btnDisable = false;
|
|
// }, 5000);
|
|
const form = new Promise((resolve, reject) => {
|
|
this.$refs["ref_form"].validate((valid) => {
|
|
if (valid) resolve();
|
|
});
|
|
});
|
|
|
|
const form1 = new Promise((resolve, reject) => {
|
|
this.$refs["ref_policy_form1"].validate((valid) => {
|
|
if (valid) resolve();
|
|
});
|
|
});
|
|
Promise.all([form1, form])
|
|
.then(() => {
|
|
var oDate1 = new Date(this.formData.serviceTimeStart);
|
|
var oDate2 = new Date(this.formData.serviceTimeEnd);
|
|
if (oDate1.getTime() > oDate2.getTime()) {
|
|
this.$message.error("服务截止时间必须大于服务开始时间");
|
|
return false;
|
|
}
|
|
this.addFuwu();
|
|
})
|
|
.catch(() => {
|
|
app.util.validateRule(messageObj);
|
|
this.btnDisable = false;
|
|
});
|
|
},
|
|
getLastItem(list, vals, key) {
|
|
let LIST = list || [];
|
|
for (let item of LIST) {
|
|
// console.log(item[key]);
|
|
for (let i of vals) {
|
|
if (item[key] === i) {
|
|
this.sarr.push(item);
|
|
} else if (item["objectType"] == "district") {
|
|
this.getLastItem(item.children, vals, key);
|
|
} else {
|
|
this.getLastItem(item.children, vals, key);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
async operationOption() {
|
|
this.sarr = [];
|
|
// 使用递归找出符合条件的数据需要
|
|
if (!this.newFormData) return;
|
|
await this.getLastItem(
|
|
this.casOptions,
|
|
this.newFormData.serviceScopeList,
|
|
"objectId"
|
|
);
|
|
//递归出的数据会有重复,因为一个街道下面有两个社区的话就会循环push两遍,在这里去重
|
|
const map = new Map();
|
|
this.newArr = this.sarr.filter(
|
|
(v) => !map.has(v.objectId) && map.set(v.objectId, 1)
|
|
);
|
|
this.newFormData.serviceScopeList = []
|
|
for (let i in this.newArr) {
|
|
this.newFormData.serviceScopeList.push({
|
|
objectId: this.newArr[i].objectId,
|
|
objectType: this.newArr[i].objectType,
|
|
objectName: this.newArr[i].objectName,
|
|
});
|
|
}
|
|
// 如果是编辑的话回填的数据会有数组字符串需要将不是对象属性的过滤掉
|
|
let arr = [];
|
|
this.newFormData.serviceScopeList.forEach((item) => {
|
|
if (typeof item != "string") {
|
|
arr.push(item);
|
|
}
|
|
});
|
|
this.newFormData.serviceScopeList = arr;
|
|
},
|
|
async addFuwu() {
|
|
// 处理服务范围数据
|
|
this.startLoading()
|
|
await this.operationOption();
|
|
this.formData.attachmentList = [...this.fileList]
|
|
let arr = []
|
|
this.formData.attachmentList.map(item=>{
|
|
arr.push({ name:item.attachmentName|| item.name,
|
|
type:item.attachmentType || item.type,
|
|
url:item.attachmentUrl || item.url,
|
|
format:item.attachmentFormat|| item.format,
|
|
duration:0,})
|
|
return arr
|
|
})
|
|
this.formData.attachmentList = arr
|
|
this.formData.assignInfo = this.newFormData;
|
|
let url = "";
|
|
|
|
if (this.formType === "add" || this.formType === "copy") {
|
|
url = "/governance/policy/addPolicy";
|
|
// this.formData.policyId = "";
|
|
} else {
|
|
url = "/governance/policy/updatePolicy";
|
|
this.formData.policyId = this.policyId;
|
|
}
|
|
|
|
if (this.formType == "copy" && this.formData.assignFlag == 0) {
|
|
this.formData.assignInfo = {
|
|
noticeApproches: [],
|
|
serverOrgId: "",
|
|
serverOrgType: "",
|
|
serviceScopeList: [],
|
|
serviceTimeEnd: "",
|
|
serviceTimeStart: "",
|
|
};
|
|
this.formData.attachmentList = [];
|
|
}
|
|
// const url = 'http://yapi.elinkservice.cn/mock/245/heart/icServiceProject/service/initiate'
|
|
let params = {
|
|
categoryCode:this.formData.categoryCode[1]?this.formData.categoryCode[1]:'',
|
|
parentCategoryCode:this.formData.categoryCode[0],
|
|
policyLevel:this.formData.policyLevel,
|
|
startDate:this.formData.startDate,
|
|
endDate:this.formData.endDate,
|
|
title:this.formData.title,
|
|
content:this.formData.content,
|
|
attachmentList:this.formData.attachmentList,
|
|
assignFlag:this.formData.assignFlag,
|
|
assignInfo:this.formData.assignInfo,
|
|
resiSearchTagId:this.formData.resiSearchTagId,
|
|
policyId:this.formData.policyId
|
|
};
|
|
const { data, code, msg } = await requestPost(url, params);
|
|
if (code === 0) {
|
|
this.$message.success("操作成功");
|
|
this.resetData();
|
|
this.$emit("handleOk");
|
|
} else {
|
|
this.btnDisable = false;
|
|
this.$message.error(msg);
|
|
}
|
|
this.endLoading()
|
|
},
|
|
async getDemandOptions() {
|
|
this.$http
|
|
.post("/actual/base/serviceitem/listAllCategory")
|
|
.then(({ data: res }) => {
|
|
if (res.code !== 0) {
|
|
return this.$message.error(res.msg);
|
|
} else {
|
|
this.demandOptions = this.getFlagDatas(
|
|
this.getTreeData(res.data),
|
|
"usableFlag"
|
|
);
|
|
}
|
|
})
|
|
.catch(() => {
|
|
return this.$message.error("网络错误");
|
|
});
|
|
},
|
|
getFlagDatas(data, flag) {
|
|
if (!Array.isArray(data)) return [];
|
|
let arr1 = data.filter((item) => item[flag]);
|
|
let arr2 = arr1.map((item) => {
|
|
if (item.childCateList)
|
|
return { ...item, childCateList: this.getFlagData(item.childCateList, flag) };
|
|
else return item;
|
|
});
|
|
// console.log('arrr-oppp', arr2)
|
|
return arr2;
|
|
},
|
|
|
|
getTreeData(data) {
|
|
if (!Array.isArray(data)) return [];
|
|
let arr = data.map((item) => {
|
|
let _item = {};
|
|
if (item.childCateList) {
|
|
if (item.childCateList.length === 0)
|
|
_item = { ...item, childCateList: undefined };
|
|
else _item = { ...item, childCateList: this.getTreeData(item.childCateList) };
|
|
} else {
|
|
_item = { ...item };
|
|
}
|
|
return _item;
|
|
});
|
|
return arr;
|
|
},
|
|
getFlagData(data, flag) {
|
|
if (!Array.isArray(data)) return [];
|
|
let arr1 = data.filter((item) => item[flag]);
|
|
let arr2 = arr1.map((item) => {
|
|
if (item.children)
|
|
return { ...item, children: this.getFlagData(item.children, flag) };
|
|
else return item;
|
|
});
|
|
// console.log('arrr-oppp', arr2)
|
|
return arr2;
|
|
},
|
|
|
|
beforeUpload(file) {
|
|
const array = file.name.split(".");
|
|
const extension = array[array.length - 1];
|
|
|
|
const formatarray = [
|
|
"jpg",
|
|
"png",
|
|
"jpeg",
|
|
"bmp",
|
|
"mp4",
|
|
"wma",
|
|
"m4a",
|
|
"mp3",
|
|
"doc",
|
|
"docx",
|
|
"xls",
|
|
"xlsx",
|
|
"pdf",
|
|
];
|
|
|
|
if (formatarray.indexOf(extension) === -1) {
|
|
this.$message.error("只支持图片、word、pdf");
|
|
return false;
|
|
}
|
|
},
|
|
|
|
handleFileRemove(file) {
|
|
if (file && file.status === "success") {
|
|
this.fileList.splice(
|
|
this.fileList.findIndex((item) => item.uid === file.uid),
|
|
1
|
|
);
|
|
}
|
|
},
|
|
|
|
handleFileSuccess(res, file) {
|
|
if (res.code === 0 && res.msg === "success") {
|
|
const array = file.name.split(".");
|
|
const fileType = array[array.length - 1];
|
|
|
|
const picArray = ["jpg", "png", "jpeg", "bmp"];
|
|
const videoarray = ["mp4", "wma", "m4a"];
|
|
const docArray = ["doc", "docx", "xls", "xlsx", "pdf"];
|
|
const mp3Array = ["mp3"];
|
|
|
|
if (picArray.indexOf(fileType) > -1) {
|
|
file.attachmentFormat = "image";
|
|
} else if (videoarray.indexOf(fileType) > -1) {
|
|
file.attachmentFormat = "video";
|
|
} else if (docArray.indexOf(fileType) > -1) {
|
|
file.attachmentFormat = "doc";
|
|
} else if (mp3Array.indexOf(fileType) > -1) {
|
|
file.attachmentFormat = "voice";
|
|
}
|
|
|
|
file.url = res.data.url;
|
|
file.type = fileType;
|
|
|
|
file.attachmentName = file.name;
|
|
file.attachmentType = file.type;
|
|
file.attachmentUrl = file.url;
|
|
|
|
this.fileList.push(file);
|
|
console.log(this.fileList);
|
|
} else this.$message.error(res.msg);
|
|
},
|
|
|
|
//下载
|
|
handleFileDownload(file) {
|
|
var a = document.createElement("a");
|
|
var event = new MouseEvent("click");
|
|
a.download = file.name;
|
|
console.log(a);
|
|
a.href = file.url;
|
|
a.dispatchEvent(event);
|
|
},
|
|
handleCancle() {
|
|
this.resetData();
|
|
this.$emit("handleClose");
|
|
},
|
|
//下载
|
|
handleFileDownload(file) {
|
|
var a = document.createElement("a");
|
|
var event = new MouseEvent("click");
|
|
a.download = file.name;
|
|
console.log(a);
|
|
a.href = file.url;
|
|
a.dispatchEvent(event);
|
|
},
|
|
|
|
resetData() {
|
|
this.formData = {
|
|
categoryCode: [],
|
|
parentCategoryCode: "",
|
|
policyLevel: "", //政府级别
|
|
startDate: "", //起始时间yyyy-MM-dd
|
|
endDate: "", //截止时间yyyy-MM-dd
|
|
title: "", //
|
|
content: "", //
|
|
attachmentList: [],
|
|
resiSearchTagName: "", //符合政策人员标签
|
|
assignFlag: 0, //是否指派服务
|
|
resiSearchTagId: "", //符合政策人员id
|
|
assignInfo: {},
|
|
};
|
|
},
|
|
// 开启加载动画
|
|
startLoading() {
|
|
loading = Loading.service({
|
|
lock: true, // 是否锁定
|
|
text: "正在加载……", // 加载中需要显示的文字
|
|
background: "rgba(0,0,0,.7)", // 背景颜色
|
|
});
|
|
},
|
|
// 结束加载动画
|
|
endLoading() {
|
|
// clearTimeout(timer);
|
|
if (loading) {
|
|
loading.close();
|
|
}
|
|
},
|
|
|
|
// 服务类型下拉框选中事件
|
|
|
|
},
|
|
computed: {
|
|
dataRule() {
|
|
return {
|
|
categoryCode: [
|
|
{ required: true, message: "政策类型不能为空", trigger: "blur" },
|
|
],
|
|
policyLevel: [
|
|
{ required: true, message: "政策级别不能为空", trigger: "change" },
|
|
],
|
|
startDate: [
|
|
{ required: true, message: "政策日期不能为空", trigger: "change" },
|
|
],
|
|
title: [
|
|
{ required: true, message: "政策标题不能为空", trigger: "change" },
|
|
],
|
|
resiSearchTagId: [
|
|
{
|
|
required: true,
|
|
message: "符合政策人员不能为空",
|
|
trigger: "change",
|
|
},
|
|
],
|
|
content: [
|
|
{ required: true, message: "政策内容不能为空", trigger: "change" },
|
|
],
|
|
};
|
|
},
|
|
},
|
|
props: {
|
|
policyId: {
|
|
type: String,
|
|
required: "",
|
|
},
|
|
|
|
formType: {
|
|
//表单操作类型 add新增,edit编辑,detail详情,feedback反馈
|
|
type: String,
|
|
required: "",
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped >
|
|
@import "@/assets/scss/modules/management/form-main.scss";
|
|
|
|
.btn-add-rule {
|
|
margin-left: 150px;
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.item_width_short {
|
|
width: 380px;
|
|
}
|
|
|
|
.item_rule {
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
}
|
|
.item_label {
|
|
flex: 0 0 150px;
|
|
line-height: 30px;
|
|
text-align: right;
|
|
padding-right: 12px;
|
|
}
|
|
.item_label:before {
|
|
content: "*";
|
|
color: #f56c6c;
|
|
margin-right: 4px;
|
|
}
|
|
</style>
|
|
|