天波用户运营管理后台系统
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.

432 line
15KB

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