天波用户运营管理后台系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 satır
14KB

  1. <!--
  2. * @Date: 2021-11-30 09:44:24
  3. * @LastEditors: JinxuChen
  4. * @LastEditTime: 2021-12-22 18:19:16
  5. * @FilePath: \GpsCardAdmin\src\views\off-limits-manage\common-exception\index.vue
  6. * @description:
  7. -->
  8. <template>
  9. <div class="app-container">
  10. <div class="filter-container">
  11. <el-button
  12. class="filter-item"
  13. style="margin-left: 10px;"
  14. type="primary"
  15. icon="el-icon-circle-plus"
  16. @click="onAdd"
  17. >添加</el-button>
  18. <!-- 下拉 -->
  19. <!-- 类别 -->
  20. <el-select
  21. v-model="model"
  22. placeholder="类别"
  23. style="width: 130px; margin-left: 10px;"
  24. filterable
  25. @change="outSelecChange"
  26. clearable
  27. v-show="false"
  28. >
  29. <el-option
  30. v-for="item in modelOptions"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value"
  34. class="filter-item"
  35. ></el-option>
  36. </el-select>
  37. <!-- 搜索 -->
  38. <el-input
  39. v-model="searchValue"
  40. :placeholder="placeholder"
  41. style="width: 200px; margin-left: 10px;"
  42. class="filter-item"
  43. @keyup.enter.native="onSearch"
  44. @clear="onClear"
  45. clearable
  46. />
  47. <el-button
  48. class="filter-item"
  49. style="margin-left: 10px;"
  50. type="primary"
  51. icon="el-icon-search"
  52. @click="onSearch"
  53. >搜索</el-button>
  54. </div>
  55. <!-- 表格 -->
  56. <!-- <el-table
  57. :key="tableKey"
  58. v-loading="listLoading"
  59. :data="list"
  60. border
  61. fit
  62. highlight-current-row
  63. style="width: 100%;"
  64. @sort-change="sortChange"
  65. ></el-table>-->
  66. <TTable :tableData="list" :columns="columns" @update="onUpdate" @delete="onDelete"></TTable>
  67. <!-- 分页 -->
  68. <pagination
  69. v-show="total>0"
  70. :total="total"
  71. ref="pages"
  72. :page.sync="page"
  73. :limit.sync="limit"
  74. @pagination="getList"
  75. />
  76. <el-dialog :visible.sync="dialogPvVisible" :title="dialogTitle">
  77. <el-form
  78. ref="form"
  79. :rules="formRules"
  80. :model="form"
  81. label-position="left"
  82. label-width="70px"
  83. >
  84. <!-- 类别 -->
  85. <el-form-item label="类别" prop="model">
  86. <el-select
  87. v-model="form.model"
  88. class="filter-item"
  89. filterable
  90. @change="onSelectChange"
  91. clearable
  92. >
  93. <el-option
  94. v-for="item in formOptions"
  95. :key="item.value"
  96. :label="item.label"
  97. :value="item.value"
  98. />
  99. </el-select>
  100. </el-form-item>
  101. <!-- 内容名称 -->
  102. <el-form-item label="内容名称" prop="content" label-width="80px" clearable>
  103. <el-input v-model="form.content" style="width: 100%" />
  104. </el-form-item>
  105. <!-- 状态 -->
  106. <el-form-item label="状态" prop="status" required>
  107. <el-switch v-model="form.status" active-text="例外" inactive-text="启用"></el-switch>
  108. <!-- <el-radio-group v-model="form.status" size="medium">
  109. <el-radio border :label="0">未启用</el-radio>
  110. <el-radio border :label="1">黑名单</el-radio>
  111. <el-radio border :label="2">白名单</el-radio>
  112. </el-radio-group> -->
  113. </el-form-item>
  114. <!-- 创建时间 -->
  115. <el-form-item label="创建时间" prop="timestamp" v-show="false">
  116. <el-date-picker v-model="form.createTime" type="datetime" />
  117. </el-form-item>
  118. </el-form>
  119. <span slot="footer" class="dialog-footer">
  120. <el-button type="error" @click="dialogPvVisible = false">取消</el-button>
  121. <el-button
  122. type="primary"
  123. @click="dialogStatus === 'update' ? update('form') : add('form')"
  124. >确认</el-button>
  125. </span>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import TTable from "../../../components/TTable/TTable";
  131. import Pagination from "@/components/Pagination";
  132. import APIExceptionGen from "@/api/common-exception";
  133. import APILimits from "@/api/off-limits-manage";
  134. export default {
  135. name: "",
  136. components: { TTable, Pagination },
  137. data() {
  138. return {
  139. model: "",
  140. searchValue: "",
  141. columns: [
  142. { prop: "type", title: "类型", fixed: 'left'},
  143. { prop: "model", title: "类别" },
  144. { prop: "content", title: "内容名称" },
  145. { prop: "createTime", title: "创建时间" },
  146. { prop: "status", title: "状态" },
  147. {
  148. action: true,
  149. title: "操作",
  150. actions: [
  151. { fnName: "update", title: "修改", type: "primary", icon: 'el-icon-edit' },
  152. { fnName: "delete", title: "删除", type: "danger", icon: 'el-icon-delete'}
  153. ]
  154. }
  155. ],
  156. list: [],
  157. total: 1,
  158. page: 1,
  159. limit: 10,
  160. type: "error",
  161. dialogPvVisible: false,
  162. dialogStatus: "",
  163. dialogTitle: "修改通用例外",
  164. modelOptions: [], //页面下拉框数据
  165. formOptions: [], //弹窗下拉数据
  166. form: {
  167. model: "",
  168. content: "",
  169. createTime: "",
  170. status: 0,
  171. id: ""
  172. },
  173. formRules: {
  174. content: [
  175. {
  176. required: true,
  177. message: "请输入内容名称",
  178. trigger: "blur"
  179. }
  180. ],
  181. model: [
  182. { required: true, message: "请选择类别", trigger: "change" }
  183. ]
  184. },
  185. placeholder: '请输入内容'
  186. };
  187. },
  188. watch: {
  189. model(value) {
  190. if (value === "") {
  191. this.getList();
  192. }
  193. },
  194. searchValue(value) {
  195. if (value === "") {
  196. this.getList();
  197. }
  198. }
  199. },
  200. methods: {
  201. // 清空表单
  202. resetForm() {
  203. this.form = {
  204. model: "",
  205. content: "",
  206. createTime: "",
  207. categoryId: "",
  208. status: false
  209. };
  210. },
  211. // 添加
  212. onAdd() {
  213. this.resetForm();
  214. this.dialogTitle = "添加通用例外";
  215. this.dialogPvVisible = true;
  216. this.dialogStatus = "add";
  217. this.getAreaCategoryQuery();
  218. },
  219. add(formName) {
  220. this.searchValue = '';
  221. let reqBody = {
  222. id: 0,
  223. categoryId: this.form.categoryId,
  224. keyword: this.form.content,
  225. status: this.checkoutStatusToNum(this.form.status),
  226. glat: 0,
  227. glng: 0,
  228. address: "",
  229. postCode: ""
  230. };
  231. this.$refs[formName].validate(valid => {
  232. if (valid) {
  233. APIExceptionGen.changeRecognitionGen(reqBody).then(res => {
  234. console.log(res);
  235. if (res.code === 0) {
  236. this.dialogPvVisible = false;
  237. this.$message({
  238. message: "增加成功",
  239. type: "success"
  240. });
  241. this.getList();
  242. }
  243. });
  244. } else {
  245. return false;
  246. }
  247. });
  248. },
  249. // 搜索
  250. onSearch() {
  251. this.$refs['pages'].currentPage = 1;
  252. this.getList();
  253. },
  254. // 修改
  255. onUpdate(row) {
  256. console.log(row);
  257. this.dialogPvVisible = true;
  258. this.dialogStatus = "update";
  259. this.dialogTitle =
  260. "修改通用例外"; /* this.form.createTime = new Date(this.form.createTime); */ // copy obj
  261. /* this.form = Object.assign({}, row); */ this.form.categoryId =
  262. row.categoryId;
  263. this.form.createTime = new Date(this.form.createTime);
  264. this.form.typeRadio = row.kindId;
  265. this.form.model = row.categoryId;
  266. this.form.id = row.id;
  267. this.form.content = row.content;
  268. this.form.status = row.status === '启用' ? false : true;
  269. },
  270. update(formName) {
  271. console.log("update");
  272. let reqBody = {
  273. id: this.form.id,
  274. categoryId: this.form.categoryId,
  275. keyword: this.form.content,
  276. status: this.checkoutStatusToNum(this.form.status),
  277. glat: 0,
  278. glng: 0,
  279. address: "",
  280. postCode: ""
  281. };
  282. this.$refs[formName].validate(valid => {
  283. if (valid) {
  284. APIExceptionGen.changeRecognitionGen(reqBody).then(res => {
  285. console.log(res);
  286. if (res.code === 0) {
  287. this.dialogPvVisible = false;
  288. this.$message({
  289. message: "修改成功",
  290. type: "success"
  291. });
  292. this.getList();
  293. }
  294. });
  295. } else {
  296. return false;
  297. }
  298. });
  299. },
  300. // 删除
  301. onDelete(row) {
  302. console.log("删除", row);
  303. this.$confirm("是否删除?", {
  304. confirmButtonText: "确定",
  305. cancelButtonText: "取消",
  306. type: "warning"
  307. })
  308. .then(() => {
  309. let reqBody = {
  310. id: row.id,
  311. type: "general"
  312. };
  313. APIExceptionGen.delRecognitionGen(reqBody).then(res => {
  314. if (res.code === 0) {
  315. this.$message({
  316. type: "success",
  317. message: "删除成功!"
  318. });
  319. this.getList();
  320. } else {
  321. this.$message({
  322. type: "error",
  323. message: "删除失败!"
  324. });
  325. }
  326. });
  327. })
  328. .catch(() => {});
  329. },
  330. // 获取分页数据
  331. getList() {
  332. let reqBody = {
  333. pageNumber: this.page,
  334. begNumber: this.limit,
  335. categoryId: this.model,
  336. keyword: this.searchValue
  337. };
  338. APIExceptionGen.getRecognitionGen(reqBody).then(res => {
  339. this.list = res.data.map(m => {
  340. return {
  341. type: this.transfromToType(m.kindId),
  342. model: m.categoryName,
  343. content: m.keyword,
  344. createTime: m.createTime,
  345. kindId: m.kindId,
  346. categoryId: m.categoryId,
  347. status: m.status === 1 ? '启用' : '例外',
  348. id: m.id
  349. };
  350. });
  351. this.total = res.count;
  352. });
  353. },
  354. // 获取类型分类
  355. getAreaCategoryQuery() {
  356. let reqBody = {
  357. pageNumber: 1,
  358. begNumber: 20,
  359. keyword: ""
  360. };
  361. APILimits.areaCategoryQuery(reqBody).then(res => {
  362. this.formOptions = res.data.map(m => {
  363. return {
  364. value: m.categoryId,
  365. label:
  366. m.categoryName +
  367. "--" +
  368. `${this.transfromToType(m.kindId)}`
  369. };
  370. });
  371. this.modelOptions = this.formOptions;
  372. });
  373. },
  374. // 弹窗选择框值变化时
  375. onSelectChange(value) {
  376. this.form.categoryId = value;
  377. },
  378. // 页面选择框变化
  379. outSelecChange(value) {
  380. this.model = value;
  381. },
  382. // 点击清除按钮时
  383. onClear() {
  384. this.$refs["pages"].currentPage = 1;
  385. this.getList();
  386. }
  387. },
  388. mounted() {
  389. this.getList();
  390. this.getAreaCategoryQuery();
  391. }
  392. };
  393. </script>
  394. <style scoped>
  395. </style>