|
@@ -0,0 +1,226 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <el-main>
|
|
|
|
+ <el-form ref="editform" :rules="rules" label-width="150px" :model="formmodel">
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-form-item :label="this.$t('convenientSync.regionLoadUrl')" prop="base_url">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="formmodel.base_url"
|
|
|
|
+ clearable
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-form-item :label="this.$t('convenientSync.hospitalSelect')" prop="hospital_id">
|
|
|
|
+ <el-select v-model="formmodel.hospital_id"
|
|
|
|
+ :placeholder="this.$t('convenientSync.hospitalSelect')" @change="hospitalChange"
|
|
|
|
+ clearable>
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="(item,index) in hospitals"
|
|
|
|
+ :key="index"
|
|
|
|
+ :label="item.shop_name"
|
|
|
|
+ :value="item.shop_id"
|
|
|
|
+ />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-form-item :label="this.$t('convenientSync.hospitalRegion')" prop="region">
|
|
|
|
+ <el-cascader :props="props" ref="cascader" clearable v-model="formmodel.region" filterable
|
|
|
|
+ @change="regionChange"></el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <!-- <el-row>-->
|
|
|
|
+ <!-- <el-col :span="24">-->
|
|
|
|
+ <!-- <el-form-item label="医院地址" prop="address">-->
|
|
|
|
+ <!-- <el-input-->
|
|
|
|
+ <!-- v-model="formmodel.address"-->
|
|
|
|
+ <!-- clearable-->
|
|
|
|
+ <!-- />-->
|
|
|
|
+ <!-- </el-form-item>-->
|
|
|
|
+ <!-- </el-col>-->
|
|
|
|
+ <!-- </el-row>-->
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-form-item :label="this.$t('convenientSync.dataSyncUrl')" prop="upload_url">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="formmodel.upload_url"
|
|
|
|
+ clearable
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <fieldset class="margin-top-sm">
|
|
|
|
+ <legend>{{this.$t('convenientSync.jsonData')}}</legend>
|
|
|
|
+ <json-viewer :expand-depth="100"
|
|
|
|
+ sort
|
|
|
|
+ :show-array-index="true"
|
|
|
|
+ copyable :value="paramExample"></json-viewer>
|
|
|
|
+ </fieldset>
|
|
|
|
+
|
|
|
|
+ <el-form-item align="center" class="margin-top-sm">
|
|
|
|
+ <el-button type="success" @click="onSubmit('editform')">{{this.$t('convenientSync.syncData')}}
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button type="danger" @click="loadPartJson">{{this.$t('convenientSync.refreshJsonData')}}
|
|
|
|
+ </el-button>
|
|
|
|
+
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-main>
|
|
|
|
+
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+ //便民服务数据结构同步
|
|
|
|
+ import * as API_ShopRegions from '@/api/shop_regions'
|
|
|
|
+ import * as API_Convenient from '@/api/ncs_convenient_sync'
|
|
|
|
+
|
|
|
|
+ const url = 'https://api.base.wdklian.com/'
|
|
|
|
+ export default {
|
|
|
|
+ name: "index",
|
|
|
|
+ data() {
|
|
|
|
+ let _this = this
|
|
|
|
+ return {
|
|
|
|
+ formmodel: {
|
|
|
|
+ base_url: url,
|
|
|
|
+ upload_url: url
|
|
|
|
+ },
|
|
|
|
+ props: {
|
|
|
|
+ lazy: true,
|
|
|
|
+ lazyLoad(node, resolve) {
|
|
|
|
+ const {level} = node;
|
|
|
|
+
|
|
|
|
+ if (level == 0) {
|
|
|
|
+ API_ShopRegions.getRegionsByDepth(level + 1, _this.formmodel.base_url).then(res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ const nodes = res.map(item => ({
|
|
|
|
+ value: item.id,
|
|
|
|
+ label: item.local_name,
|
|
|
|
+ leaf: false
|
|
|
|
+ }));
|
|
|
|
+ resolve(nodes);
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ const {value} = node.data
|
|
|
|
+ API_ShopRegions.getRegionsChildren(value, _this.formmodel.base_url).then(res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ const nodes = res.map(item => ({
|
|
|
|
+ value: item.id,
|
|
|
|
+ label: item.local_name,
|
|
|
|
+ leaf: item.bool_leaf
|
|
|
|
+ }));
|
|
|
|
+ resolve(nodes);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ hospitals: [],
|
|
|
|
+ paramExample: {},
|
|
|
|
+ rules: {
|
|
|
|
+ region: [
|
|
|
|
+ {required: true, message: this.$t('convenientSync.selectHospitalPls'), trigger: 'blur'}
|
|
|
|
+ ],
|
|
|
|
+ hospital_id: [
|
|
|
|
+ {required: true, message: this.$t('convenientSync.selectRegionPls'), trigger: 'blur'}
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.getHospitals()
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ onSubmit(formName) {
|
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ this.formmodel.json = JSON.stringify(this.paramExample)
|
|
|
|
+ API_Convenient.structSync(this.formmodel.upload_url, this.formmodel).then(() => {
|
|
|
|
+
|
|
|
|
+ this.$message.success(this.$t('action.saveSuccess'))
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error(this.$t('action.fromError'))
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ loadPartJson() {
|
|
|
|
+ if(this.formmodel.hospital_id){
|
|
|
|
+ this.getJSON(this.formmodel.hospital_id)
|
|
|
|
+ }else{
|
|
|
|
+ this.$message.error(this.$t('convenientSync.selectHospitalPls'))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ getHospitals() {
|
|
|
|
+ API_Convenient.getPartList(6).then(res => {
|
|
|
|
+ this.hospitals = [...res]
|
|
|
|
+ if(res.length>0){
|
|
|
|
+ this.formmodel.hospital_id=res[0].shop_id
|
|
|
|
+ this.loadPartJson()
|
|
|
|
+ }
|
|
|
|
+ }).catch(err => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ regionChange(val) {
|
|
|
|
+ if (val) {
|
|
|
|
+ this.formmodel.region = val[val.length - 1]
|
|
|
|
+ } else {
|
|
|
|
+ this.formmodel.region = null
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ hospitalChange(val) {
|
|
|
|
+ if (val) {
|
|
|
|
+ this.getJSON(val)
|
|
|
|
+ } else {
|
|
|
|
+ this.paramExample = {}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ getJSON(val) {
|
|
|
|
+ API_Convenient.getShopList(val).then(res => {
|
|
|
|
+ const partList = res.map(item => ({
|
|
|
|
+ shopName: item.shop_name,
|
|
|
|
+ unionId: item.union_id
|
|
|
|
+ }))
|
|
|
|
+ const hosptial = this.hospitals.find(p => p.shop_id === val)
|
|
|
|
+ const {shop_name, union_id} = hosptial
|
|
|
|
+ this.paramExample = {shopName: shop_name, unionId: union_id, partList}
|
|
|
|
+
|
|
|
|
+ }).catch(err => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style scoped>
|
|
|
|
+ /deep/ .el-cascader--medium {
|
|
|
|
+ width: 100%
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fieldset {
|
|
|
|
+ border: 1px solid #DCDFE6;
|
|
|
|
+ border-radius: 5px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .margin-top-sm {
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ }
|
|
|
|
+</style>
|