LocalGuide.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="dydj">
  3. <div class="communal-list">
  4. <div class="communal-title">
  5. <div>导游地接资料</div>
  6. <div class="communal-box">
  7. <el-input @input="Inquireclick()" placeholder="请输入单位地区/单位名称/联系人/联系电话" v-model="input" clearable
  8. style="width: 350px;">
  9. </el-input>
  10. <router-link to="/home/LocalGuideOperation">
  11. <el-button type="primary" style="margin-left: 10px;">新增</el-button>
  12. </router-link>
  13. </div>
  14. </div>
  15. <template>
  16. <el-table :data="tableDatas.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border
  17. style="width: 100%" v-loading="loading" element-loading-text="拼命加载中..." :cell-class-name="addClass">
  18. <el-table-column prop="num" label="序 号" width="55">
  19. <template slot-scope="scope">
  20. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="unitArea" label="单位地区" width="180">
  24. <template slot-scope="scope">
  25. {{scope.row.unitArea|filter_emptyAcquiesce}}
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="unitName" label="单位名称">
  29. <template slot-scope="scope">
  30. {{scope.row.unitName|filter_emptyAcquiesce}}
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="contact" label="联系人" width="220">
  34. <template slot-scope="scope">
  35. {{scope.row.contact|filter_emptyAcquiesce}}
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="contactTel" label="联系电话" width="180">
  39. <template slot-scope="scope">
  40. {{scope.row.contactTel|filter_emptyAcquiesce}}
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="score" label="评分" width="55">
  44. <template slot-scope="scope">
  45. {{scope.row.score|filter_emptyAcquiesce}}
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="lastUpdate" label="更新时间" width="180">
  49. <template slot-scope="scope">
  50. {{scope.row.lastUpdate|filter_emptyAcquiesce}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="操作">
  54. <template slot-scope="scope">
  55. <el-button size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
  56. <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </template>
  61. <div class="block">
  62. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  63. :current-page="currentPage" :page-sizes="[10, 12, 15, 20]" :page-size="pageSize"
  64. layout="total, sizes, prev, pager, next" :total="tableDatas.length">
  65. </el-pagination>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. export default {
  72. beforeRouteLeave(to, from, next) {
  73. if(to.name!='LocalGuideOperation'){
  74. localStorage.removeItem('dydjval');
  75. }
  76. next()
  77. },
  78. data() {
  79. return {
  80. loading: false,
  81. tableDatas: [],
  82. tableData: [],
  83. currentPage: 1, // 当前页码
  84. pageSize: 12,// 每页的数据条数
  85. input: '',
  86. token: '',
  87. userId: 0,
  88. unitAreas: [],
  89. restaurants: [],
  90. }
  91. },
  92. methods: {
  93. //每页条数改变时触发 选择一页显示多少行
  94. handleSizeChange(val) {
  95. this.currentPage = 1;
  96. this.pageSize = val;
  97. },
  98. //当前页改变时触发 跳转其他页
  99. handleCurrentChange(val) {
  100. this.currentPage = val;
  101. },
  102. LocalGuide() {
  103. this.loading = true
  104. var url = "/api/Resource/QueryLocalGuide"
  105. var that = this
  106. this.$axios({
  107. method: 'post',
  108. url: url,
  109. headers: {
  110. Authorization: 'Bearer ' + this.token
  111. },
  112. data: {
  113. portType: 1,
  114. pageIndex: 0,
  115. pageSize: 0,
  116. unitName: "",
  117. unitArea: "",
  118. contact: "",
  119. contactTel: ""
  120. }
  121. }).then(function (res) {
  122. console.log(res)
  123. if (res.data.code == 200) {
  124. that.tableData = res.data.data;
  125. that.tableDatas = that.tableData;
  126. that.tableData.forEach(function (item, index) {
  127. that.unitAreas.push({
  128. value: item.unitArea,
  129. });
  130. });
  131. if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
  132. if (that.currentPage > 1) {
  133. that.currentPage = that.currentPage - 1;
  134. }
  135. }
  136. if(JSON.parse(localStorage.getItem('dydjval'))){
  137. that.currentPage=JSON.parse(localStorage.getItem('dydjval')).currentPage;
  138. that.input=JSON.parse(localStorage.getItem('dydjval')).input;
  139. var newarr = [];
  140. if (that.input == "") {
  141. newarr = that.tableData;
  142. } else {
  143. console.log(that.tableData);
  144. for (var i = 0; i < that.tableData.length; i++) {
  145. if (that.tableData[i].unitArea.indexOf(that.input) != -1) {
  146. newarr.push(that.tableData[i]);
  147. } else if (that.tableData[i].unitName.indexOf(that.input) != -1) {
  148. newarr.push(that.tableData[i]);
  149. } else if (that.tableData[i].contact.indexOf(that.input) != -1) {
  150. newarr.push(that.tableData[i]);
  151. } else if (that.tableData[i].contactTel.indexOf(that.input) != -1) {
  152. newarr.push(that.tableData[i]);
  153. }
  154. }
  155. }
  156. that.tableDatas = newarr;
  157. }
  158. }
  159. that.loading = false
  160. console.log(that.tableDatas);
  161. }).catch(function (error) {
  162. that.loading = false
  163. that.$message.error("网络错误,请稍后重试");
  164. });
  165. },
  166. //搜索框处理
  167. Inquireclick() {
  168. var newarr = [];
  169. if (this.input == "") {
  170. newarr = this.tableData;
  171. } else {
  172. for (var i = 0; i < this.tableData.length; i++) {
  173. if (this.tableData[i].unitArea.indexOf(this.input) != -1) {
  174. newarr.push(this.tableData[i]);
  175. } else if (this.tableData[i].unitName.indexOf(this.input) != -1) {
  176. newarr.push(this.tableData[i]);
  177. } else if (this.tableData[i].contact.indexOf(this.input) != -1) {
  178. newarr.push(this.tableData[i]);
  179. } else if (this.tableData[i].contactTel.indexOf(this.input) != -1) {
  180. newarr.push(this.tableData[i]);
  181. }
  182. }
  183. }
  184. this.tableDatas = newarr;
  185. this.currentPage = 1;
  186. },
  187. //条件颜色
  188. addClass({row,column,rowIndex,columnIndex}){
  189. if(row.lastUpdateDays >= 365){
  190. return 'cell-grey';
  191. }
  192. },
  193. upDate(index, row) {
  194. var dydjval={
  195. currentPage:this.currentPage,
  196. input:this.input,
  197. }
  198. localStorage.setItem('dydjval', JSON.stringify(dydjval));
  199. this.$router.push({
  200. path: "/home/LocalGuideOperation",
  201. query: { id: row.id }
  202. })
  203. },
  204. del(index, row) {
  205. this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
  206. confirmButtonText: '确定',
  207. cancelButtonText: '取消',
  208. type: 'warning'
  209. }).then(() => {
  210. var url = "/api/Resource/DelLocalGuide"
  211. var that = this
  212. this.$axios({
  213. method: 'post',
  214. url: url,
  215. headers: {
  216. Authorization: 'Bearer ' + this.token
  217. },
  218. data: {
  219. Id: row.id,
  220. DeleteUserId: this.userId
  221. }
  222. }).then(function (res) {
  223. console.log(res)
  224. if (res.data.code == 200) {
  225. that.$message({
  226. message: '删除成功',
  227. type: 'success'
  228. });
  229. that.LocalGuide();
  230. } else {
  231. that.$message.error('删除失败!');
  232. }
  233. that.loading = false
  234. }).catch(function (error) {
  235. that.loading = false
  236. that.$message.error("网络错误,请稍后重试");
  237. });
  238. }).catch(() => {
  239. this.$message({
  240. type: 'info',
  241. message: '操作已取消!'
  242. });
  243. });
  244. }
  245. },
  246. filters:{
  247. //空默认值
  248. filter_emptyAcquiesce(value) {
  249. let fhz= value==""?"--":value
  250. return fhz
  251. },
  252. },
  253. mounted() {
  254. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  255. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  256. this.LocalGuide();
  257. }
  258. }
  259. </script>
  260. <style>
  261. .communal-list {
  262. background-color: #fff;
  263. padding: 10px;
  264. box-shadow: 0 0 5px #0005;
  265. border-radius: 10px;
  266. }
  267. .communal-title {
  268. display: flex;
  269. font-size: 17px;
  270. font-weight: 600;
  271. color: #555;
  272. margin-top: 8px;
  273. margin-bottom: 10px;
  274. justify-content: space-between;
  275. align-items: center;
  276. }
  277. .communal-box {
  278. display: flex;
  279. }
  280. .communal-box>button {
  281. margin-left: 10px;
  282. padding: 8px 20px;
  283. }
  284. .dydj .cell-grey{
  285. color: red;
  286. }
  287. </style>