|
@@ -1,235 +1,240 @@
|
|
|
-<template>
|
|
|
- <div id="addroute">
|
|
|
- <el-row>
|
|
|
- <el-col :span="24" class="container">
|
|
|
- <el-col :span="24" class="top">
|
|
|
- <el-button type="primary" size="mini" style="float:left" @click="$router.go(-1)">返回</el-button>
|
|
|
- <el-button type="primary" size="mini" style="float:right" @click="dialog = true">添加</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="info">
|
|
|
- <data-table
|
|
|
- :fields="fields"
|
|
|
- :data="list"
|
|
|
- :opera="opera"
|
|
|
- :total="total"
|
|
|
- :size="50"
|
|
|
- :step="10"
|
|
|
- @editor="editor"
|
|
|
- @addstyle="addstyle"
|
|
|
- @delete="toDelete"
|
|
|
- @query="search"
|
|
|
- :toFormat="roleSelect"
|
|
|
- ></data-table>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-dialog :visible.sync="dialog" title="线路详情" @close="toClose" width="50%">
|
|
|
- <!-- 物流里面的:data要换成v-model -->
|
|
|
-
|
|
|
- <data-form v-model="form" :fields="fields" @save="turnSave" :rules="rules" @filterReturn="choose">
|
|
|
- <template #options="{item}">
|
|
|
- <template v-if="item.model == 's_p'">
|
|
|
- <el-option v-for="(item, index) in routeList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
- </template>
|
|
|
- <template v-if="item.model == 's_c'">
|
|
|
- <el-option v-for="(item, index) in startCityList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
- </template>
|
|
|
- <template v-if="item.model == 'e_p'">
|
|
|
- <el-option v-for="(item, index) in routeList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
- </template>
|
|
|
- <template v-if="item.model == 'e_c'">
|
|
|
- <el-option v-for="(item, index) in endCityList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </data-form>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions: route } = createNamespacedHelpers('route');
|
|
|
-const { mapActions: dictionary } = createNamespacedHelpers('dictionary');
|
|
|
-
|
|
|
-export default {
|
|
|
- metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
- },
|
|
|
- name: 'addroute',
|
|
|
- props: {},
|
|
|
- components: {},
|
|
|
- data: function() {
|
|
|
- return {
|
|
|
- fields: [
|
|
|
- { label: '所属项目', model: 'item', notable: true, noform: true },
|
|
|
- { label: '起始地省份', model: 's_p', filter: 'input', type: 'select', filterReturn: true, format: true },
|
|
|
- { label: '起始地城市', model: 's_c', filter: 'input', type: 'select', format: true },
|
|
|
- { label: '目的地省份', model: 'e_p', filter: 'input', type: 'select', filterReturn: true, format: true },
|
|
|
- { label: '目的地城市', model: 'e_c', filter: 'input', type: 'select', format: true },
|
|
|
- { label: '路线名称', model: 'name', filter: 'input' },
|
|
|
- { label: '起始站点', model: 'start' },
|
|
|
- { label: '目的站点', model: 'end' },
|
|
|
- {
|
|
|
- label: '状态',
|
|
|
- model: 'status',
|
|
|
- filter: 'select',
|
|
|
- type: 'select',
|
|
|
- format: i => (i === '0' ? '使用' : '禁用'),
|
|
|
- list: [
|
|
|
- { label: '使用', value: '0' },
|
|
|
- { label: '禁用', value: '1' },
|
|
|
- ],
|
|
|
- },
|
|
|
- { label: '创始人', model: 'owner', notable: true, noform: true },
|
|
|
- ],
|
|
|
- list: [],
|
|
|
- total: 0,
|
|
|
- opera: [
|
|
|
- { label: '编辑', method: 'editor' },
|
|
|
- { label: '添加方式', method: 'addstyle' },
|
|
|
- { label: '删除', method: 'delete' },
|
|
|
- ],
|
|
|
- dialog: false,
|
|
|
- form: {},
|
|
|
- rules: {
|
|
|
- s_p: [{ required: true, message: '请输入起始地省份', trigger: 'blur' }],
|
|
|
- e_p: [{ required: true, message: '请输入目的地省份', trigger: 'blur' }],
|
|
|
- },
|
|
|
- //线路列表
|
|
|
- routeList: [],
|
|
|
- //起始地城市列表
|
|
|
- startCityList: [],
|
|
|
- //目的地城市列表
|
|
|
- endCityList: [],
|
|
|
- };
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.search();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- ...route(['query', 'create', 'update', 'delete']),
|
|
|
- ...dictionary(['tree']),
|
|
|
- async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
- const res = await this.query({ skip, limit, ...info, item: this.id });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- const { data, total } = res;
|
|
|
- this.$set(this, `list`, data);
|
|
|
- this.$set(this, `total`, total);
|
|
|
- }
|
|
|
- //查线路列表
|
|
|
- const res3 = await this.tree('xzqh');
|
|
|
- // console.log(res3);
|
|
|
- if (res3) {
|
|
|
- this.$set(this, `routeList`, res3);
|
|
|
- }
|
|
|
- },
|
|
|
- //关闭
|
|
|
- toClose() {
|
|
|
- this.dialog = false;
|
|
|
- this.form = {};
|
|
|
- },
|
|
|
- //保存
|
|
|
- async turnSave({ data }) {
|
|
|
- let res;
|
|
|
- let word;
|
|
|
- if (data.id) {
|
|
|
- res = await this.update(data);
|
|
|
- word = '修改';
|
|
|
- // if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
|
|
|
- // this.search();
|
|
|
- // this.toClose();
|
|
|
- // }
|
|
|
- } else {
|
|
|
- data.item = this.id;
|
|
|
- data.owner = this.user.id;
|
|
|
- res = await this.create(data);
|
|
|
- word = '创建';
|
|
|
- // if (this.$checkRes(res, '创建成功', res.errmsg || '创建失败')) {
|
|
|
- // this.search();
|
|
|
- // this.toClose();
|
|
|
- // }
|
|
|
- }
|
|
|
- if (this.$checkRes(res, `${word}成功`, res.errmsg || `${word}失败`)) {
|
|
|
- this.search();
|
|
|
- this.toClose();
|
|
|
- }
|
|
|
- },
|
|
|
- //编辑
|
|
|
- editor({ data }) {
|
|
|
- this.$set(this, `form`, data);
|
|
|
- this.dialog = true;
|
|
|
- this.choose({ data: data.s_p, model: 's_p' });
|
|
|
- this.choose({ data: data.e_p, model: 'e_p' });
|
|
|
- },
|
|
|
- //刪除
|
|
|
- async toDelete({ data }) {
|
|
|
- const res = await this.delete(data.id);
|
|
|
- if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) {
|
|
|
- this.search();
|
|
|
- }
|
|
|
- },
|
|
|
- //增加方式
|
|
|
- addstyle({ data }) {
|
|
|
- this.$router.push({ path: '/client/addstyle', query: { id: data.id } });
|
|
|
- },
|
|
|
- choose({ data, model }) {
|
|
|
- let startCity = this.routeList.find(i => i.id === data);
|
|
|
- if (model === 's_p') {
|
|
|
- this.$set(this, `startCityList`, startCity.children);
|
|
|
- } else {
|
|
|
- this.$set(this, `endCityList`, startCity.children);
|
|
|
- }
|
|
|
- //显示城市用的代码
|
|
|
- // if (model === 's_p') {
|
|
|
- // if (startCity.children.length !== 0) {
|
|
|
- // this.$set(this, `startCityList`, startCity.children);
|
|
|
- // } else {
|
|
|
- // this.$set(this, `startCityList`, [startCity]);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // if (startCity.children.length !== 0) {
|
|
|
- // this.$set(this, `endCityList`, startCity.children);
|
|
|
- // } else {
|
|
|
- // this.$set(this, `endCityList`, [startCity]);
|
|
|
- // }
|
|
|
- // }
|
|
|
- },
|
|
|
- //过滤
|
|
|
- roleSelect({ model, value }) {
|
|
|
- if (model == 's_p' || model == 'e_p') {
|
|
|
- let arr = this.routeList.find(i => i.id === value);
|
|
|
- if (arr) return arr.label;
|
|
|
- } else if (model == 's_c' || model == 'e_c') {
|
|
|
- //显示城市用的代码
|
|
|
- // let arr1 = this.routeList.find(i => i.id === value);
|
|
|
- // if (arr1) {
|
|
|
- // return arr1.label;
|
|
|
- // } else {
|
|
|
- // for (let item of this.routeList) {
|
|
|
- // let arr = item.children.find(i => i.id === value);
|
|
|
- // if (arr) return arr.label;
|
|
|
- // }
|
|
|
- // }
|
|
|
- for (let item of this.routeList) {
|
|
|
- let arr = item.children.find(i => i.id === value);
|
|
|
- if (arr) return arr.label;
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapState(['user']),
|
|
|
- id() {
|
|
|
- return this.$route.query.id;
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
-</script>
|
|
|
-
|
|
|
-<style lang="less" scoped>
|
|
|
-.container {
|
|
|
- .top {
|
|
|
- margin: 15px 0;
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|
|
|
+<template>
|
|
|
+ <div id="addroute">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="container">
|
|
|
+ <el-col :span="24" class="top">
|
|
|
+ <el-button type="primary" size="mini" style="float:left" @click="$router.go(-1)">返回</el-button>
|
|
|
+ <el-button type="primary" size="mini" style="float:right" @click="dialog = true">添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <data-table
|
|
|
+ :fields="fields"
|
|
|
+ :data="list"
|
|
|
+ :opera="opera"
|
|
|
+ :total="total"
|
|
|
+ :size="50"
|
|
|
+ :step="10"
|
|
|
+ @editor="editor"
|
|
|
+ @addstyle="addstyle"
|
|
|
+ @delete="toDelete"
|
|
|
+ @query="search"
|
|
|
+ :toFormat="modelFormat"
|
|
|
+ ></data-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-dialog :visible.sync="dialog" title="线路详情" @close="toClose" width="50%">
|
|
|
+ <!-- 物流里面的:data要换成v-model -->
|
|
|
+
|
|
|
+ <data-form v-model="form" :fields="fields" @save="turnSave" :rules="rules" @filterReturn="choose">
|
|
|
+ <template #options="{item}">
|
|
|
+ <template v-if="item.model == 's_p'">
|
|
|
+ <el-option v-for="(item, index) in routeList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template v-if="item.model == 's_c'">
|
|
|
+ <el-option v-for="(item, index) in startCityList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template v-if="item.model == 'e_p'">
|
|
|
+ <el-option v-for="(item, index) in routeList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template v-if="item.model == 'e_c'">
|
|
|
+ <el-option v-for="(item, index) in endCityList" :key="index" :label="item.label" :value="item.id"></el-option>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: route } = createNamespacedHelpers('route');
|
|
|
+const { mapActions: dictionary } = createNamespacedHelpers('dictionary');
|
|
|
+
|
|
|
+export default {
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+ name: 'addroute',
|
|
|
+ props: {},
|
|
|
+ components: {},
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ fields: [
|
|
|
+ { label: '所属项目', model: 'item', notable: true, noform: true },
|
|
|
+ { label: '起始地省份', model: 's_p', filter: 'input', type: 'select', filterReturn: true, format: true },
|
|
|
+ { label: '起始地城市', model: 's_c', filter: 'input', type: 'select', format: true },
|
|
|
+ { label: '目的地省份', model: 'e_p', filter: 'input', type: 'select', filterReturn: true, format: true },
|
|
|
+ { label: '目的地城市', model: 'e_c', filter: 'input', type: 'select', format: true },
|
|
|
+ { label: '路线名称', model: 'name', filter: 'input' },
|
|
|
+ { label: '起始站点', model: 'start' },
|
|
|
+ { label: '目的站点', model: 'end' },
|
|
|
+ {
|
|
|
+ label: '状态',
|
|
|
+ model: 'status',
|
|
|
+ filter: 'select',
|
|
|
+ type: 'select',
|
|
|
+ format: i => (i === '0' ? '使用' : '禁用'),
|
|
|
+ list: [
|
|
|
+ { label: '使用', value: '0' },
|
|
|
+ { label: '禁用', value: '1' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ { label: '创始人', model: 'owner', notable: true, noform: true },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ opera: [
|
|
|
+ { label: '编辑', method: 'editor' },
|
|
|
+ { label: '添加方式', method: 'addstyle' },
|
|
|
+ { label: '删除', method: 'delete' },
|
|
|
+ ],
|
|
|
+ dialog: false,
|
|
|
+ form: {},
|
|
|
+ rules: {
|
|
|
+ s_p: [{ required: true, message: '请输入起始地省份', trigger: 'blur' }],
|
|
|
+ e_p: [{ required: true, message: '请输入目的地省份', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ //线路列表
|
|
|
+ routeList: [],
|
|
|
+ //起始地城市列表
|
|
|
+ startCityList: [],
|
|
|
+ //目的地城市列表
|
|
|
+ endCityList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ this.getRoutes();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...route(['query', 'create', 'update', 'delete']),
|
|
|
+ ...dictionary(['tree']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, ...info, item: this.id });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const { data, total } = res;
|
|
|
+ this.$set(this, `list`, data);
|
|
|
+ this.$set(this, `total`, total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //关闭
|
|
|
+ toClose() {
|
|
|
+ this.dialog = false;
|
|
|
+ this.form = {};
|
|
|
+ },
|
|
|
+ //保存
|
|
|
+ async turnSave({ data }) {
|
|
|
+ let res;
|
|
|
+ let word;
|
|
|
+ if (data.id) {
|
|
|
+ res = await this.update(data);
|
|
|
+ word = '修改';
|
|
|
+ // if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
|
|
|
+ // this.search();
|
|
|
+ // this.toClose();
|
|
|
+ // }
|
|
|
+ } else {
|
|
|
+ data.item = this.id;
|
|
|
+ data.owner = this.user.id;
|
|
|
+ res = await this.create(data);
|
|
|
+ word = '创建';
|
|
|
+ // if (this.$checkRes(res, '创建成功', res.errmsg || '创建失败')) {
|
|
|
+ // this.search();
|
|
|
+ // this.toClose();
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, `${word}成功`, res.errmsg || `${word}失败`)) {
|
|
|
+ this.search();
|
|
|
+ this.toClose();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //编辑
|
|
|
+ editor({ data }) {
|
|
|
+ this.$set(this, `form`, data);
|
|
|
+ this.dialog = true;
|
|
|
+ this.choose({ data: data.s_p, model: 's_p' });
|
|
|
+ this.choose({ data: data.e_p, model: 'e_p' });
|
|
|
+ },
|
|
|
+ //刪除
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const res = await this.delete(data.id);
|
|
|
+ if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //增加方式
|
|
|
+ addstyle({ data }) {
|
|
|
+ this.$router.push({ path: '/client/addstyle', query: { id: data.id } });
|
|
|
+ },
|
|
|
+ choose({ data, model }) {
|
|
|
+ let startCity = this.routeList.find(i => i.id === data);
|
|
|
+ if (model === 's_p') {
|
|
|
+ this.$set(this, `startCityList`, startCity.children);
|
|
|
+ } else {
|
|
|
+ this.$set(this, `endCityList`, startCity.children);
|
|
|
+ }
|
|
|
+ //显示城市用的代码
|
|
|
+ // if (model === 's_p') {
|
|
|
+ // if (startCity.children.length !== 0) {
|
|
|
+ // this.$set(this, `startCityList`, startCity.children);
|
|
|
+ // } else {
|
|
|
+ // this.$set(this, `startCityList`, [startCity]);
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if (startCity.children.length !== 0) {
|
|
|
+ // this.$set(this, `endCityList`, startCity.children);
|
|
|
+ // } else {
|
|
|
+ // this.$set(this, `endCityList`, [startCity]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ //过滤
|
|
|
+ modelFormat({ model, value }) {
|
|
|
+ console.log(model, value);
|
|
|
+ if (model == 's_p' || model == 'e_p') {
|
|
|
+ let arr = this.routeList.find(i => i.id === value);
|
|
|
+ if (arr) return arr.label;
|
|
|
+ } else if (model == 's_c' || model == 'e_c') {
|
|
|
+ //显示城市用的代码
|
|
|
+ // let arr1 = this.routeList.find(i => i.id === value);
|
|
|
+ // if (arr1) {
|
|
|
+ // return arr1.label;
|
|
|
+ // } else {
|
|
|
+ // for (let item of this.routeList) {
|
|
|
+ // let arr = item.children.find(i => i.id === value);
|
|
|
+ // if (arr) return arr.label;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ for (let item of this.routeList) {
|
|
|
+ let arr = item.children.find(i => i.id === value);
|
|
|
+ if (arr) return arr.label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取路线
|
|
|
+ async getRoutes() {
|
|
|
+ //查线路列表
|
|
|
+ const res3 = await this.tree({ categroy: 'xzqh' });
|
|
|
+ // console.log(res3);
|
|
|
+ if (res3) {
|
|
|
+ this.$set(this, `routeList`, res3);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.container {
|
|
|
+ .top {
|
|
|
+ margin: 15px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|