天波用户运营管理后台系统
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

394 lines
13KB

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