123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840 |
- <template>
- <div class="mainBox">
- <!--搜索功能 start------------------------------------------------------------>
- <div class="layerBox_search">
- <el-row>
- <el-col :span="8">
- <div class="searchBox">
- <div class="searchTitle">栏目名称:</div>
- <el-input v-model="getApiData.name" placeholder="请输入栏目名称" :clearable="true" @clear="onInputClear" />
- <!-- <el-input placeholder="请输入栏目名称" autocomplete="off" v-model="getApiData.name" /> -->
- </div>
- </el-col>
- </el-row>
- </div>
- <div class="layerBoxNoBg">
- <div>
- <el-button type="primary" @click="addCategoryList()">添加栏目名称</el-button>
- </div>
- <div>
- <el-button @click="clearSearchList">重置</el-button>
- <el-button type="primary" style="margin-right:20px" @click="getData('search')">搜索</el-button>
- </div>
- </div>
- <!--搜索功能 end------------------------------------------------------------>
- <!--表格内容 start------------------------------------------------------------>
- <div class="layerBox">
- <tableTitle :name="tableDivTitle" />
- <el-row>
- <template>
- <el-table :data="tableData" style="width: 100%" row-key="id" :default-expand-all="isExpandAll"
- :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
- <el-table-column fixed prop="id" label="编号" width="150"></el-table-column>
- <el-table-column prop="name" label="栏目名称">
- <template slot-scope="scope">
- <span :class="{ highlight: isHighlight(scope.row, search) }" v-if="scope.row.pid == 0">{{ scope.row.name
- }}</span>
- <span :class="{ highlight: isHighlight(scope.row, search) }" v-else>____{{ scope.row.name }}</span>
- </template>
- </el-table-column>
- <el-table-column label="是否外链" align="center">
- <template slot-scope="scope">
- <div>
- {{ scope.row.is_url ? '是' : "否" }}
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="created_at" label="创建时间"></el-table-column>
- <el-table-column prop="updated_at" label="修改时间"></el-table-column>
- <el-table-column fixed="right" label="操作" width="230" header-align="center">
- <template slot-scope="scope">
- <div class="listBtnBox">
- <div class="listDeleteBtn" @click="deleteData(scope.row.id, tableData)"><i
- class="el-icon-delete"></i>删除</div>
- <div class="listEditBtn" @click="getDataMain(scope.row.id, tableData)"><i
- class="el-icon-edit-outline"></i>编辑</div>
- <div class="listMainBtn" @click="addCategoryList(scope.row)"><i class="el-icon-document-add"></i>添加
- </div>
- </div>
- <!-- <el-button @click.native.prevent="deleteData(scope.row.id, tableData)" type="text" size="small">删除</el-button>
- <el-button @click.native.prevent="getDataMain(scope.row.id, tableData)" type="text" size="small">编辑</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- </template>
- </el-row>
- </div>
- <!--分页 start------------------------------------------------------------>
- <div class="alignBox">
- <el-row>
- <el-col :span="24">
- <el-pagination :current-page="getApiData.page" @size-change="handleSizeChange"
- @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
- :total="allCount"></el-pagination>
- </el-col>
- </el-row>
- </div>
- <!--分页 end------------------------------------------------------------>
- <!--表格内容 end------------------------------------------------------------>
- <!--弹出框 start------------------------------------------------------------>
- <el-dialog :title="editId ? '编辑栏目名称' : '添加栏目名称'" :visible.sync="windowStatus" :close-on-click-modal="false"
- @close="clearToServe(2)">
- <el-form :model="form" ref="form" :rules="formRules" autocomplete="off" label-position="left">
- <div class="formDiv">
- <el-form-item label="栏目名称:" :label-width="formLabelWidth" prop="name" class="custom-align-right">
- <el-input v-model="form.name" autocomplete="off" placeholder="请输入栏目名称"></el-input>
- <el-checkbox v-model="show_url" @change="ifUrl">引用外链</el-checkbox>
- </el-form-item>
- <div v-if="show_url == 1">
- <el-form-item label="外链地址:" :label-width="formLabelWidth" prop="web_url" class="custom-align-right">
- <el-input v-model="form.web_url" autocomplete="off" placeholder="请输入外链地址"></el-input>
- </el-form-item>
- <el-form-item label="栏目标题:" :label-width="formLabelWidth" prop="seo_title" class="custom-align-right">
- <el-input v-model="form.seo_title" autocomplete="off" placeholder="请输入栏目标题"></el-input>
- </el-form-item>
- <el-form-item label="栏目关键词:" :label-width="formLabelWidth" prop="seo_keywords" class="custom-align-right">
- <!-- <el-input v-model="form.seo_keywords" autocomplete="off" placeholder="请输入栏目关键词"></el-input> -->
- <inputTag :initialTags="tags" @tags-updated="updateTags" />
- </el-form-item>
- <el-form-item label="栏目描述:" :label-width="formLabelWidth" prop="seo_description" class="custom-align-right">
- <el-input type="textarea" v-model="form.seo_description" placeholder="请输入栏目描述"></el-input>
- </el-form-item>
- <!-- <el-form-item label="排序:" :label-width="formLabelWidth" class="custom-align-right">
- <el-input v-model="form.sort" autocomplete="off" placeholder="请输入排序"></el-input>
- </el-form-item> -->
- </div>
- <div v-if="show_url == 0">
- <!-- <el-form-item label="关联职能部门:" :label-width="formLabelWidth" prop="department_arr_id" class="custom-align-right"> -->
- <!-- <el-cascader :key="departmentKey" v-model="form.department_arr_id" placeholder="选择要绑定的职能部门" :props="departmentData" filterable clearable></el-cascader> -->
- <!-- <el-cascader :key="departmentKey" :props="{value:'id',label:'name',children:'children'}" :options="allDepartment" v-model="form.department_arr_id" :show-all-levels="false" filterable />
- </el-form-item> -->
- <!-- <el-form-item label="关联行政区划:" :label-width="formLabelWidth" prop="city_arr_id" class="custom-align-right">
- <el-cascader :key="cascaderKey" v-model="form.city_arr_id" placeholder="选择要绑定行政区划" :props="cityData" filterable clearable></el-cascader>
- </el-form-item> -->
- <el-form-item label="父级栏目:" :label-width="formLabelWidth" class="custom-align-right">
- <el-cascader :key="parentKey" v-model="form.pid_arr" placeholder="请选择要绑定的父级栏目" :props="parentData"
- filterable clearable></el-cascader>
- </el-form-item>
- <el-form-item label="栏目类型:" :label-width="formLabelWidth" prop="type" class="custom-align-right">
- <template #label>
- <span class="askBox">
- 栏目类型:
- <el-tooltip class="item" effect="dark" content=" 选择类型提交后不可更改,请谨慎考虑后提交!" placement="top">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </span>
- </template>
- <el-radio-group v-model="form.type" size="small" :disabled="editId ? true : false">
- <el-radio-button label="1">资讯</el-radio-button>
- <el-radio-button label="2">商品</el-radio-button>
- <el-radio-button label="3">书刊音响</el-radio-button>
- <el-radio-button label="4">招聘</el-radio-button>
- <el-radio-button label="5">求职</el-radio-button>
- </el-radio-group>
- <!-- 选择类型提交后不可更改,请谨慎考虑后提交! 提示词 -->
- <div style="color: brown;">
- 选择类型提交后不可更改,请谨慎考虑后提交!
- </div>
- </el-form-item>
- <el-form-item label="栏目标题:" :label-width="formLabelWidth" prop="seo_title" class="custom-align-right">
- <template #label>
- <span class="askBox">
- 栏目标题:
- <el-tooltip class="item" effect="dark" content="栏目标题,如:三农市场网_农资产品商城_网站列表_全国信息一体化网络平台_项目大全。"
- placement="top">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </span>
- </template>
- <el-input v-model="form.seo_title" autocomplete="off" placeholder="请输入栏目标题"></el-input>
- </el-form-item>
- <el-form-item label="栏目关键词:" :label-width="formLabelWidth" prop="seo_keywords" class="custom-align-right">
- <template #label>
- <span class="askBox">
- 栏目关键词:
- <el-tooltip class="item" effect="dark" content="栏目关键词,如:三农市场网、农资产品商城、全国三农、信息一体化。" placement="top">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </span>
- </template>
- <!-- <el-input v-model="form.seo_keywords" autocomplete="off" placeholder="请输入栏目关键词"></el-input> -->
- <inputTag :initialTags="tags" @tags-updated="updateTags" />
- </el-form-item>
- <el-form-item label="栏目描述:" :label-width="formLabelWidth" prop="seo_description" class="custom-align-right">
- <template #label>
- <span class="askBox">
- 栏目描述:
- <el-tooltip class="item" effect="dark" content="栏目描述,如:中国三农市场网,农资产品商城属市场类频道,共有5个栏目。" placement="top">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </span>
- </template>
- <el-input type="textarea" v-model="form.seo_description" class="custom-textarea"
- placeholder="请输入栏目描述"></el-input>
- </el-form-item>
- <!-- <el-form-item label="排序:" :label-width="formLabelWidth" class="custom-align-right">
- <el-input v-model="form.sort" autocomplete="off" placeholder="请输入排序"></el-input>
- </el-form-item> -->
- </div>
- </div>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="closeWindow">取 消</el-button>
- <el-button type="primary" @click="editToServe" v-if="editBtn == true">确定</el-button>
- <el-button type="primary" @click="addToServe" v-else>提交</el-button>
- </div>
- </el-dialog>
- <!--弹出框 end------------------------------------------------------------>
- </div>
- </template>
- <script>
- //表格标题
- import tableTitle from './components/tableTitle';
- import InputTag from '@/components/InputTag';
- //引入公用样式
- import '@/styles/global.less';
- export default {
- components: {
- tableTitle,//表格标题
- InputTag
- },
- data() {
- //0.全局操作 start ------------------------------------------------------------>
- //表单验证
- const validateEmpty = (rule, value, callback) => {
- if (value.length == 0) {
- callback(new Error('该项不能为空!'))
- } else {
- callback()
- }
- }
- // const validateDepartment = (rule,value,callback) => {
- // if (value.length === 0) {
- // callback(new Error('请选择职能部门!'))
- // } else {
- // callback()
- // }
- // }
- // const validateCity = (rule,value,callback) => {
- // if (value.length === 0) {
- // callback(new Error('请选择行政区划!'))
- // } else {
- // callback()
- // }
- // }
- const validatePid = (rule, value, callback) => {
- if (value.length === 0) {
- callback(new Error('请选择父级栏目!'))
- } else {
- callback()
- }
- }
- let self = this;
- //0.全局操作 end ------------------------------------------------------------>
- return {
- isExpandAll: false,
- search: '',
- tags: [],
- //1.列表和分页相关 start ------------------------------------------------------------>
- tableDivTitle: "栏目名称列表",
- tableData: [],//内容
- allCount: 0,//总条数
- editId: 0,//要修改的网站id
- getApiData: {
- name: "",//栏目池名称查询
- // department_id:[],//行政职能部门id
- // city_id:[],//行政区划
- page: 1,//当前是第几页
- pageSize: 10,//一共多少条
- },
- allDepartment: [],//所有职能
- //列表和分页相关 end ------------------------------------------------------------>
- //2.搜索相关 start ------------------------------------------------------------>
- //行政职能部门
- searchDepartmentKey: 0, //列表缓存key
- // searchDepartmentData: {
- // checkStrictly: true,
- // lazy: true,
- // async lazyLoad (node, resolve) {
- // const { level, data } = node;
- // if (data && data.children && data.children.length !== 0) {
- // return resolve(node)
- // }
- // console.log(level)
- // let parentId = level == 0 ? 0 : data.value
- // let parames = {
- // 'pid':parentId
- // }
- // self.$store.dispatch('pool/getDepartment',parames).then(res=> {
- // if (res.data) {
- // const nodes = res.data.map(item => ({
- // value: item.id,
- // label: item.name,
- // leaf: level >= 3,
- // children: []
- // }))
- // resolve(nodes)
- // }
- // })
- // }
- // },
- //获取城市列表
- searchCascaderKey: 0, //列表缓存key
- searchCityData: {
- checkStrictly: true,
- lazy: true,
- async lazyLoad(node, resolve) {
- const { level, data } = node;
- if (data && data.children && data.children.length !== 0) {
- return resolve(node)
- }
- console.log(level)
- let parentId = level == 0 ? 0 : data.value
- let parames = {
- 'pid': parentId
- }
- self.$store.dispatch('pool/getcityList', parames).then(res => {
- if (res.data) {
- const nodes = res.data.map(item => ({
- value: item.id,
- label: item.name,
- leaf: level >= 3,
- children: []
- }))
- resolve(nodes)
- }
- })
- }
- },
- //搜索相关 end ------------------------------------------------------------>
- //3.弹出框设置 start ------------------------------------------------------------>
- windowStatus: false, //显示弹出框
- formLabelWidth: '140px',
- show_url: false, //是否显示外链输入框
- editBtn: false,//当显示编辑按钮的时候,就不显示提交
- //弹出框设置 end ------------------------------------------------------------>
- //4.弹出框中的表单设置 start ------------------------------------------------------------>
- //4.1表单收集的数据
- form: {
- name: '',//栏目池名称
- is_url: 0,//是否为外链,0=否 1=是
- web_url: "",//外链地址
- // department_arr_id:[],//职能部门
- // city_arr_id:[],//行政区划
- sort: 0,//排序
- //pid:2,
- seo_title: "",//标题
- seo_keywords: "",//关键词
- seo_description: "",//描述
- type: 1,//栏目类型
- pid_arr: []//父级栏目
- },
- //4.2表单验证规则
- formRules: {
- //网站名称不能为空
- name: [{ required: true, trigger: 'blur', validator: validateEmpty }],//栏目池名称不能为空
- web_url: [{ required: true, trigger: 'blur', validator: validateEmpty }],//外链地址不能为空
- // department_arr_id: [{type:'array',required:true,trigger:'change',message:'请选择职能部门!',validator:validateDepartment}],
- // city_arr_id: [{type:'array',required:true,trigger:'change',message:'请选择行政区划!',validator:validateCity}],
- // pid_arr: [{type:'array',required:true,trigger:'change',message:'请选择父级栏目!',validator:validatePid}],
- seo_title: [{ required: true, trigger: 'blur', validator: validateEmpty }],//标题不能为空
- seo_keywords: [{ required: true, trigger: 'blur', validator: validateEmpty }],//关键词不能为空
- seo_description: [{ required: true, trigger: 'blur', validator: validateEmpty }],//描述不能为空
- },
- //获取城市列表
- cascaderKey: 0,//弹窗用的key
- cityData: {
- checkStrictly: true,
- lazy: true,
- async lazyLoad(node, resolve) {
- const { level, data } = node;
- if (data && data.children && data.children.length !== 0) {
- return resolve(node)
- }
- console.log(level)
- let parentId = level == 0 ? 0 : data.value
- let parames = {
- 'pid': parentId
- }
- self.$store.dispatch('pool/getcityList', parames).then(res => {
- if (res.data) {
- const nodes = res.data.map(item => ({
- value: item.id,
- label: item.name,
- leaf: level >= 3,
- children: []
- }))
- resolve(nodes)
- }
- })
- }
- },
- //获取职能部门
- departmentKey: 0,//弹窗用的key
- // departmentData: {
- // checkStrictly: true,//父级不可选
- // lazy: true,
- // async lazyLoad (node, resolve) {
- // const { level, data } = node;
- // if (data && data.children && data.children.length !== 0) {
- // return resolve(node)
- // }
- // console.log(level)
- // let parentId = level == 0 ? 0 : data.value
- // let parames = {
- // 'pid':parentId
- // }
- // self.$store.dispatch('pool/getDepartment',parames).then(res=> {
- // if (res.data) {
- // const nodes = res.data.map(item => ({
- // value: item.id,
- // label: item.name,
- // leaf: level >= 3,
- // children: []
- // }))
- // resolve(nodes)
- // }
- // })
- // }
- // },
- parentKey: 0,//获取父级栏目
- parentData: {
- checkStrictly: true,
- lazy: true,
- async lazyLoad(node, resolve) {
- const { level, data } = node;
- if (data && data.children && data.children.length !== 0) {
- return resolve(node)
- }
- console.log(level)
- let parentId = level == 0 ? 0 : data.value
- let parames = {
- 'pid': parentId
- }
- self.$store.dispatch('pool/categoryList', parames).then(res => {
- if (res.data) {
- const nodes = res.data.map(item => ({
- value: item.id,
- label: item.name,
- leaf: level >= 3,
- children: []
- }))
- resolve(nodes)
- }
- })
- }
- },
- //弹出框中的表单设置 end ------------------------------------------------------------>
- }
- },
- methods: {
- onInputClear() {
- this.isExpandAll = false;
- this.getData();
- },
- //1.列表和分页相关 start ------------------------------------------------------------>
- //1.1 开始请求列表信息方法
- getData(type) {
- if (type == 'search') {
- this.getApiData.page = 1
- this.isExpandAll = true;
- } else {
- this.isExpandAll = false;
- }
- //搜索条件
- // if(this.getApiData.department_id.length>0){
- // //网系只提交最后一个
- // this.getApiData.department_id = this.getApiData.department_id[this.getApiData.department_id.length - 1];
- // }
- // if(this.getApiData.city_id.length>0){
- // //城市id只提交最后一个
- // this.getApiData.city_id = this.getApiData.city_id[this.getApiData.city_id.length - 1];
- // }
- //如果是搜索,重新加载第一页
- this.$store.dispatch('pool/getCategoryList', this.getApiData).then(res => {
- // console.log("=============:",res.data)
- this.tableData = res.data.rows; //��与内容
- this.allCount = res.data.total
- }).catch(() => {
- this.$message({
- type: 'warning',
- message: '网络错误,请重试!'
- });
- })
- },
- //1.2 删除内容
- deleteData(id) {
- this.$confirm('删除后,该条信息及其绑定关系全部删除,确定吗', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- console.log("当前删除:" + id)
- this.$store.dispatch('pool/delCategory', { id: id }).then(res => {
- if (res.code == 200) {
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- } else if (res.code == 0) {
- this.$message({
- type: 'warning',
- message: res.message
- });
- }
- this.getData();
- }).catch(() => {
- this.$message({
- type: 'warning',
- message: '网络错误,请重试!'
- });
- })
- }).catch(() => {
- this.$message({
- type: 'warning',
- message: '已取消删除'
- });
- });
- },
- //1.3 直接跳转
- handleSizeChange(val) {
- this.getApiData.page = val;
- this.getData();
- },
- //1.4 点击分页
- handleCurrentChange(val) {
- this.getApiData.page = val;
- this.getData();
- },
- //1.5 重置按钮
- clearSearchList() {
- this.isExpandAll = false;
- this.tableData = [];
- this.getApiData.name = "";
- // this.getApiData.department_id = [];
- // this.getApiData.city_id = [];
- this.getApiData.page = 1;
- this.getApiData.pageSize = 10;
- this.getData();
- },
- //1.6 获取所有职能
- getAllDepartment() {
- this.$store.dispatch('cms/getAllDepartment').then(res => {
- // console.log(res)
- this.allDepartment = res.data;
- })
- },
- //列表和分页相关 end ------------------------------------------------------------>
- //2.弹出框设置 start ------------------------------------------------------------>
- //2.1 打开弹出框
- openWindow() {
- //this.clearToServe();
- this.windowStatus = true;
- },
- //2.1.1 添加栏目池
- addCategoryList(row) {
- this.form.pid_arr = [];
- this.show_url = false;
- // this.form.is_url = 0;
- this.editId = 0;
- this.editBtn = false;
- this.tags = []
- if (row) {
- if (row.pid == 0) {
- this.form.pid_arr.push(row.id)
- } else {
- let pidArr = [];
- // console.log("fuck:",row.pid_arr);
- pidArr = JSON.parse(row.pid_arr)
- pidArr.push(row.id)
- this.form.pid_arr = pidArr
- // console.log('追加id:',this.form.pid_arr)
- }
- }
- // console.log("=========:", this.form.pid_arr)
- this.openWindow();
- },
- //2.2 关闭弹出框
- closeWindow() {
- this.windowStatus = false;
- this.clearToServe(2);
- },
- //2.3 清理弹出框
- clearToServe(type) {
- if (type == 1) { //type1 使用了外部链接
- // this.form.department_arr_id = [];
- // this.form.city_arr_id = [];
- this.form.pid_arr = [];
- }
- if (type == 2) { //type2 全部清理
- this.form.name = "";
- this.form.is_url = 0;
- this.form.web_url = "";
- // this.form.department_arr_id = [];
- // this.form.city_arr_id = [];
- this.form.sort = 0;
- this.form.seo_title = "";
- this.form.seo_keywords = "";
- this.form.seo_description = "";
- this.form.pid_arr = [];
- //存在验证的时候再清理
- if (this.$refs.form && this.$refs.form.fields.some(field => field.validateState === 'error')) {
- this.$refs.form.clearValidate();
- }
- }
- },
- //弹出框设置 end ------------------------------------------------------------>
- //3.添加栏目池 start ------------------------------------------------------------>
- ifUrl(value) {
- console.log(value)
- if (value == true) {
- this.form.is_url = 1
- } else {
- this.form.is_url = 0
- }
- this.$refs.form.clearValidate();
- },
- addToServe() {
- //先判断是否使用了外链
- if (this.show_url == true) {
- this.clearToServe(1)
- }
- //判断有没有添加父级栏目
- if (this.form.pid_arr.length == 0) {
- this.form.pid_arr = [0];
- }
- this.$refs.form.validate(valid => {
- if (valid) {
- this.$store.dispatch('pool/addCategory', this.form).then(res => {
- //汇报结果
- this.$message({
- type: 'success',
- message: '已成功添加栏目池!'
- });
- //清空并退出
- this.closeWindow();
- this.getData();
- }).catch(() => {
- this.$message({
- type: 'warning',
- message: '网络错误,请重试!'
- });
- })
- }
- })
- },
- //添加栏目池 end ------------------------------------------------------------>
- //编辑栏目池 start ------------------------------------------------------------>
- getDataMain(id) {
- //先清空窗口
- this.clearToServe(2)
- //打开输入窗口
- this.openWindow();
- //添加修改id
- this.editId = id;
- //获取网站详情
- this.$store.dispatch('pool/getCategoryInfo', { id: id }).then(res => {
- //清除错误状态
- //this.$refs.form.clearValidate();
- // console.log(res)
- //回显栏目池名称
- this.form.name = res.data.name;
- //回显示是否使用外链
- if (res.data.is_url == 1) {
- this.show_url = true;
- } else if (res.data.is_url == 0 || res.data.is_url == null) {
- this.show_url = false;
- }
- // console.log(res.data.is_url)
- this.form.is_url = res.data.is_url;
- //回显外链
- this.form.web_url = res.data.web_url;
- //回显行政区划
- // this.form.city_arr_id = JSON.parse(res.data.city_arr_id);
- // //当cascaderKey的值改变的时候 级联选择器会重置里面的内容
- // this.cascaderKey += 1;
- // this.loadCascaderPath(this.form.city_arr_id,"xzqh");
- //回显父级栏目
- this.form.pid_arr = JSON.parse(res.data.pid_arr);
- this.parentKey += 1;
- // this.loadCascaderPath(this.form.pid_arr,"fjdh");
- //回显职能部门
- // this.form.department_arr_id = JSON.parse(res.data.department_arr_id);
- // this.departmentKey += 1;
- // this.loadCascaderPath(this.form.department_arr_id,"znbm");
- //回显栏目池标题,描述,关键词
- this.form.seo_title = res.data.seo_title;
- this.form.seo_keywords = res.data.seo_keywords;
- this.tags = res.data.seo_keywords ? res.data.seo_keywords.split(',') : [];
- this.form.seo_description = res.data.seo_description;
- this.form.type = res.data.type;
- //回显排序
- this.form.sort = res.data.sort;
- })
- this.editBtn = true;//显示编辑按钮
- },
- //回显行政区划
- // async loadCascaderPath(path,type) {
- // for (let i = 0; i < path.length; i++) {
- // const parentId = path[i - 1] || 0; // 获取当前层级的父级ID
- // const level = i; // 当前层级的索引
- // await this.$store.dispatch('pool/getcityList', { pid: parentId })
- // .then((res) => {
- // const nodes = res.data.map(item => ({
- // value: item.id,
- // label: item.name,
- // leaf: level >= 3, // 这里假设4层结构,设置叶子节点标记
- // }));
- // // 将数据传递到 resolve,通知 cascader 这一层的数据加载完毕
- // if (level === path.length - 1) {
- // if(type=="xzqh"){this.form.city_arr_id = path;}
- // if(type=="fjdh"){this.form.pid_arr = path;}
- // if(type=="znbm"){this.form.department_arr_id = path;}
- // }
- // });
- // }
- // },
- //修改表单
- editToServe() {
- //防止提交[1,1]这种重复的数据
- // if (this.form.department_arr_id.length > 1) {
- // const lastIndex = this.form.department_arr_id.length - 1;
- // if (this.form.department_arr_id[lastIndex] === this.form.department_arr_id[lastIndex - 1]) {
- // this.form.department_arr_id.pop(); // Remove the last element if it's the same as the previous one
- // }
- // }
- this.form.id = this.editId;
- this.$refs.form.validate(valid => {
- if (valid) {
- //提交表单
- this.$store.dispatch('pool/updateCategory', this.form).then(res => {
- //汇报结果
- this.$message({
- type: 'success',
- message: '已成功修改栏目池信息!'
- });
- //清空并退出
- this.closeWindow();
- this.getData();
- }).catch(() => {
- this.$message({
- type: 'warning',
- message: '网络错误,请重试!'
- });
- })
- }
- })
- },
- //关键词
- updateTags(newTags) {
- // this.foem.seo_keywords = newTags;
- this.tags = newTags;
- this.form.seo_keywords = newTags.join(',');
- },
- isHighlight(row, search) {
- if (!search) return false;
- const lowerSearch = search.toLowerCase();
- return row.name.toLowerCase().includes(lowerSearch);
- },
- //编辑栏目池 end ------------------------------------------------------------>
- },
- mounted() {
- //1.获得初始数据
- this.getData();
- //2.获取所有网系
- //this.getwebsiteColumn();
- //本地转换id为文字
- //console.log(getLocationNameById("110000"))
- this.getAllDepartment();
- }
- }
- </script>
- <style scoped lang="less">
- ::v-deep .highlight {
- background-color: yellow;
- }
- //表单微调 start------------------------------------------------------------>*/
- ::v-deep .custom-form-item>.el-form-item__label {
- line-height: 140px !important;
- }
- ::v-deep .custom-textarea .el-textarea__inner {
- resize: none;
- /* 禁止用���拖拽调整大小 */
- }
- ::v-deep .custom-align-right .el-form-item__label {
- text-align: right;
- /* 设置标签文字右对齐 */
- }
- .collector {
- margin-left: 0px;
- padding-left: 0px;
- margin-right: 20px;
- width: 76px;
- height: 36px;
- line-height: 36px;
- position: relative;
- .collectorIcon {
- display: inline-block;
- width: 20px;
- height: 20px;
- background: url("../../assets/advertise/Graph.png");
- vertical-align: middle;
- margin-right: 6px;
- }
- .collectorIcon1 {
- position: absolute;
- top: 12px;
- left: 8px;
- }
- }
- .collector {
- text-align: center;
- border-radius: 8px;
- cursor: pointer;
- color: #519C66;
- background-color: rgba(81, 156, 102, 0.16);
- >i {
- padding-right: 8px;
- }
- }
- //表单微调 end------------------------------------------------------------>*/</style>
|