123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <div class="dydj">
- <div class="communal-list">
- <div class="communal-title">
- <div>导游地接资料</div>
- <div class="communal-box">
- <el-input @input="Inquireclick()" placeholder="请输入单位地区/单位名称/联系人/联系电话" v-model="input" clearable
- style="width: 350px;">
- </el-input>
- <router-link to="/home/LocalGuideOperation">
- <el-button type="primary" style="margin-left: 10px;">新增</el-button>
- </router-link>
- </div>
- </div>
- <template>
- <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
- style="width: 100%" v-loading="loading" element-loading-text="拼命加载中..." :cell-class-name="addClass">
- <el-table-column prop="num" label="序 号" width="55">
- <template slot-scope="scope">
- {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
- </template>
- </el-table-column>
- <el-table-column prop="unitArea" label="单位地区" width="180">
- <template slot-scope="scope">
- {{scope.row.unitArea|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column prop="unitName" label="单位名称">
- <template slot-scope="scope">
- {{scope.row.unitName|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column prop="contact" label="联系人" width="220">
- <template slot-scope="scope">
- {{scope.row.contact|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column prop="contactTel" label="联系电话" width="180">
- <template slot-scope="scope">
- {{scope.row.contactTel|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column prop="score" label="评分" width="55">
- <template slot-scope="scope">
- {{scope.row.score|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column prop="lastUpdate" label="更新时间" width="180">
- <template slot-scope="scope">
- {{scope.row.lastUpdate|filter_emptyAcquiesce}}
- </template>
- </el-table-column>
- <el-table-column label="操作">
- <template slot-scope="scope">
- <el-button size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
- <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </template>
- <div class="block">
- <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
- :current-page="currentPage" :page-sizes="[10, 12, 15, 20]" :page-size="pageSize"
- layout="total, sizes, prev, pager, next" :total="tableDatas.length">
- </el-pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- beforeRouteLeave(to, from, next) {
- if(to.name!='LocalGuideOperation'){
- localStorage.removeItem('dydjval');
- }
- next()
- },
- data() {
- return {
- loading: false,
- tableDatas: [],
- tableData: [],
- currentPage: 1, // 当前页码
- pageSize: 12,// 每页的数据条数
- input: '',
- token: '',
- userId: 0,
- unitAreas: [],
- restaurants: [],
- }
- },
- methods: {
-
- //每页条数改变时触发 选择一页显示多少行
- handleSizeChange(val) {
- this.currentPage = 1;
- this.pageSize = val;
- },
- //当前页改变时触发 跳转其他页
- handleCurrentChange(val) {
- this.currentPage = val;
- },
- LocalGuide() {
- this.loading = true
- var url = "/api/Resource/QueryLocalGuide"
- var that = this
- this.$axios({
- method: 'post',
- url: url,
- headers: {
- Authorization: 'Bearer ' + this.token
- },
- data: {
- portType: 1,
- pageIndex: 0,
- pageSize: 0,
- unitName: "",
- unitArea: "",
- contact: "",
- contactTel: ""
- }
- }).then(function (res) {
- console.log(res)
- if (res.data.code == 200) {
- that.tableData = res.data.data;
- that.tableDatas = that.tableData;
- that.tableData.forEach(function (item, index) {
- that.unitAreas.push({
- value: item.unitArea,
- });
- });
- if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
- if (that.currentPage > 1) {
- that.currentPage = that.currentPage - 1;
- }
- }
- if(JSON.parse(localStorage.getItem('dydjval'))){
- that.currentPage=JSON.parse(localStorage.getItem('dydjval')).currentPage;
- that.input=JSON.parse(localStorage.getItem('dydjval')).input;
- var newarr = [];
- if (that.input == "") {
- newarr = that.tableData;
- } else {
- console.log(that.tableData);
- for (var i = 0; i < that.tableData.length; i++) {
- if (that.tableData[i].unitArea.indexOf(that.input) != -1) {
- newarr.push(that.tableData[i]);
- } else if (that.tableData[i].unitName.indexOf(that.input) != -1) {
- newarr.push(that.tableData[i]);
- } else if (that.tableData[i].contact.indexOf(that.input) != -1) {
- newarr.push(that.tableData[i]);
- } else if (that.tableData[i].contactTel.indexOf(that.input) != -1) {
- newarr.push(that.tableData[i]);
- }
- }
- }
- that.tableDatas = newarr;
- }
- }
- that.loading = false
- console.log(that.tableDatas);
- }).catch(function (error) {
- that.loading = false
- that.$message.error("网络错误,请稍后重试");
- });
- },
- //搜索框处理
- Inquireclick() {
- var newarr = [];
- if (this.input == "") {
- newarr = this.tableData;
- } else {
- for (var i = 0; i < this.tableData.length; i++) {
- if (this.tableData[i].unitArea.indexOf(this.input) != -1) {
- newarr.push(this.tableData[i]);
- } else if (this.tableData[i].unitName.indexOf(this.input) != -1) {
- newarr.push(this.tableData[i]);
- } else if (this.tableData[i].contact.indexOf(this.input) != -1) {
- newarr.push(this.tableData[i]);
- } else if (this.tableData[i].contactTel.indexOf(this.input) != -1) {
- newarr.push(this.tableData[i]);
- }
- }
- }
- this.tableDatas = newarr;
- this.currentPage = 1;
- },
- //条件颜色
- addClass({row,column,rowIndex,columnIndex}){
- if(row.lastUpdateDays >= 365){
- return 'cell-grey';
- }
- },
- upDate(index, row) {
- var dydjval={
- currentPage:this.currentPage,
- input:this.input,
- }
- localStorage.setItem('dydjval', JSON.stringify(dydjval));
- this.$router.push({
- path: "/home/LocalGuideOperation",
- query: { id: row.id }
- })
- },
- del(index, row) {
- this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- var url = "/api/Resource/DelLocalGuide"
- var that = this
- this.$axios({
- method: 'post',
- url: url,
- headers: {
- Authorization: 'Bearer ' + this.token
- },
- data: {
- Id: row.id,
- DeleteUserId: this.userId
- }
- }).then(function (res) {
- console.log(res)
- if (res.data.code == 200) {
- that.$message({
- message: '删除成功',
- type: 'success'
- });
- that.LocalGuide();
- } else {
- that.$message.error('删除失败!');
- }
- that.loading = false
- }).catch(function (error) {
- that.loading = false
- that.$message.error("网络错误,请稍后重试");
- });
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '操作已取消!'
- });
- });
- }
- },
- filters:{
- //空默认值
- filter_emptyAcquiesce(value) {
- let fhz= value==""?"--":value
- return fhz
- },
- },
- mounted() {
- this.token = JSON.parse(localStorage.getItem('userinif')).token;
- this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
- this.LocalGuide();
-
- }
- }
- </script>
- <style>
- .communal-list {
- background-color: #fff;
- padding: 10px;
- box-shadow: 0 0 5px #0005;
- border-radius: 10px;
- }
- .communal-title {
- display: flex;
- font-size: 17px;
- font-weight: 600;
- color: #555;
- margin-top: 8px;
- margin-bottom: 10px;
- justify-content: space-between;
- align-items: center;
- }
- .communal-box {
- display: flex;
- }
- .communal-box>button {
- margin-left: 10px;
- padding: 8px 20px;
- }
- .dydj .cell-grey{
- color: red;
- }
- </style>
|