天波用户运营管理后台系统
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

393 行
13KB

  1. <!--
  2. * @Date: 2021-11-30 09:44:24
  3. * @LastEditors: JinxuChen
  4. * @LastEditTime: 2021-12-10 11:32:57
  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. >
  28. <el-option
  29. v-for="item in modelOptions"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. class="filter-item"
  34. ></el-option>
  35. </el-select>
  36. <!-- 搜索 -->
  37. <el-input
  38. v-model="searchValue"
  39. placeholder="请输入关键字"
  40. style="width: 200px; margin-left: 10px;"
  41. class="filter-item"
  42. @keyup.enter.native="onSearch"
  43. @clear="onClear"
  44. clearable
  45. />
  46. <el-button
  47. class="filter-item"
  48. style="margin-left: 10px;"
  49. type="primary"
  50. icon="el-icon-search"
  51. @click="onSearch"
  52. >搜索</el-button>
  53. </div>
  54. <!-- 表格 -->
  55. <!-- <el-table
  56. :key="tableKey"
  57. v-loading="listLoading"
  58. :data="list"
  59. border
  60. fit
  61. highlight-current-row
  62. style="width: 100%;"
  63. @sort-change="sortChange"
  64. ></el-table>-->
  65. <TTable :tableData="list" :columns="columns" @update="onUpdate" @delete="onDelete"></TTable>
  66. <!-- 分页 -->
  67. <pagination
  68. v-show="total>0"
  69. :total="total"
  70. ref="pages"
  71. :page.sync="page"
  72. :limit.sync="limit"
  73. @pagination="getList"
  74. />
  75. <el-dialog :visible.sync="dialogPvVisible" :title="dialogTitle">
  76. <el-form
  77. ref="form"
  78. :rules="formRules"
  79. :model="form"
  80. label-position="left"
  81. label-width="70px"
  82. style="width: 400px;"
  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: 80%" />
  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-form-item>
  109. <!-- 创建时间 -->
  110. <el-form-item label="创建时间" prop="timestamp" v-show="false">
  111. <el-date-picker v-model="form.createTime" type="datetime" />
  112. </el-form-item>
  113. </el-form>
  114. <span slot="footer" class="dialog-footer">
  115. <el-button type="error" @click="dialogPvVisible = false">取消</el-button>
  116. <el-button
  117. type="primary"
  118. @click="dialogStatus === 'update' ? update('form') : add('form')"
  119. >确认</el-button>
  120. </span>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import TopMenu from "@/components/TopMenu";
  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, TopMenu, 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. };
  182. },
  183. watch: {
  184. model(value) {
  185. if (value === "") {
  186. this.getList();
  187. }
  188. },
  189. searchValue(value) {
  190. if (value === "") {
  191. this.getList();
  192. }
  193. }
  194. },
  195. methods: {
  196. // 清空表单
  197. resetForm() {
  198. this.form = {
  199. model: "",
  200. content: "",
  201. createTime: "",
  202. categoryId: "",
  203. status: true
  204. };
  205. },
  206. // 添加
  207. onAdd() {
  208. this.resetForm();
  209. this.dialogTitle = "添加通用例外";
  210. this.dialogPvVisible = true;
  211. this.dialogStatus = "add";
  212. this.getAreaCategoryQuery();
  213. },
  214. add(formName) {
  215. this.searchValue = '';
  216. let reqBody = {
  217. id: 0,
  218. categoryId: this.form.categoryId,
  219. keyword: this.form.content,
  220. status: this.form.status,
  221. glat: 0,
  222. glng: 0,
  223. address: "",
  224. postCode: ""
  225. };
  226. this.$refs[formName].validate(valid => {
  227. if (valid) {
  228. APIExceptionGen.changeRecognitionGen(reqBody).then(res => {
  229. console.log(res);
  230. if (res.code === 0) {
  231. this.dialogPvVisible = false;
  232. this.$message({
  233. message: "增加成功",
  234. type: "success"
  235. });
  236. this.getList();
  237. }
  238. });
  239. } else {
  240. return false;
  241. }
  242. });
  243. },
  244. // 搜索
  245. onSearch() {
  246. this.$refs['pages'].currentPage = 1;
  247. this.getList();
  248. },
  249. // 修改
  250. onUpdate(row) {
  251. console.log(row);
  252. this.dialogPvVisible = true;
  253. this.dialogStatus = "update";
  254. this.dialogTitle =
  255. "修改通用例外"; /* this.form.createTime = new Date(this.form.createTime); */ // copy obj
  256. /* this.form = Object.assign({}, row); */ this.form.categoryId =
  257. row.categoryId;
  258. this.form.createTime = new Date(this.form.createTime);
  259. this.form.typeRadio = row.kindId;
  260. this.form.model = row.categoryId;
  261. this.form.id = row.id;
  262. this.form.content = row.content;
  263. this.form.status = row.status === '打开' ? true : false;
  264. },
  265. update(formName) {
  266. console.log("update");
  267. let reqBody = {
  268. id: this.form.id,
  269. categoryId: this.form.categoryId,
  270. keyword: this.form.content,
  271. status: this.form.status,
  272. glat: 0,
  273. glng: 0,
  274. address: "",
  275. postCode: ""
  276. };
  277. this.$refs[formName].validate(valid => {
  278. if (valid) {
  279. APIExceptionGen.changeRecognitionGen(reqBody).then(res => {
  280. console.log(res);
  281. if (res.code === 0) {
  282. this.dialogPvVisible = false;
  283. this.$message({
  284. message: "修改成功",
  285. type: "success"
  286. });
  287. this.getList();
  288. }
  289. });
  290. } else {
  291. return false;
  292. }
  293. });
  294. },
  295. // 删除
  296. onDelete(row) {
  297. console.log("删除", row);
  298. this.$confirm("是否删除?", {
  299. confirmButtonText: "确定",
  300. cancelButtonText: "取消",
  301. type: "warning"
  302. })
  303. .then(() => {
  304. let reqBody = {
  305. id: row.id,
  306. type: "general"
  307. };
  308. APIExceptionGen.delRecognitionGen(reqBody).then(res => {
  309. if (res.code === 0) {
  310. this.$message({
  311. type: "success",
  312. message: "删除成功!"
  313. });
  314. this.getList();
  315. } else {
  316. this.$message({
  317. type: "error",
  318. message: "删除失败!"
  319. });
  320. }
  321. });
  322. })
  323. .catch(() => {});
  324. },
  325. // 获取分页数据
  326. getList() {
  327. let reqBody = {
  328. pageNumber: this.page,
  329. begNumber: this.limit,
  330. categoryId: this.model,
  331. keyword: this.searchValue
  332. };
  333. APIExceptionGen.getRecognitionGen(reqBody).then(res => {
  334. this.list = res.data.map(m => {
  335. return {
  336. type: this.transfromToType(m.kindId),
  337. model: m.categoryName,
  338. content: m.keyword,
  339. createTime: m.createTime,
  340. kindId: m.kindId,
  341. categoryId: m.categoryId,
  342. status: m.status === true ? '打开' : '关闭',
  343. id: m.id
  344. };
  345. });
  346. this.total = res.count;
  347. });
  348. },
  349. // 获取类型分类
  350. getAreaCategoryQuery() {
  351. let reqBody = {
  352. pageNumber: 1,
  353. begNumber: 20,
  354. keyword: ""
  355. };
  356. APILimits.areaCategoryQuery(reqBody).then(res => {
  357. this.formOptions = res.data.map(m => {
  358. return {
  359. value: m.categoryId,
  360. label:
  361. m.categoryName +
  362. "--" +
  363. `${this.transfromToType(m.kindId)}`
  364. };
  365. });
  366. this.modelOptions = this.formOptions;
  367. });
  368. },
  369. // 弹窗选择框值变化时
  370. onSelectChange(value) {
  371. this.form.categoryId = value;
  372. },
  373. // 页面选择框变化
  374. outSelecChange(value) {
  375. this.model = value;
  376. },
  377. // 点击清除按钮时
  378. onClear() {
  379. this.$refs["pages"].currentPage = 1;
  380. this.getList();
  381. }
  382. },
  383. mounted() {
  384. this.getList();
  385. this.getAreaCategoryQuery();
  386. }
  387. };
  388. </script>
  389. <style scoped>
  390. </style>