bait.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <!-- -->
  2. <template>
  3. <div class="cbdbox">
  4. <div class="cbdboxs_search">
  5. <el-input
  6. v-model="queryInfo.inducer_name"
  7. placeholder="请输入诱剂名称"
  8. size="mini"
  9. ></el-input>
  10. <el-button type="info" @click="search" size="mini">搜索</el-button>
  11. <el-button
  12. type="info"
  13. size="mini"
  14. @click="
  15. addtraptf = true;
  16. addtitle = '新增诱剂';
  17. "
  18. >添加诱剂</el-button
  19. >
  20. </div>
  21. <el-card class="box-card" style="margin-top: 15px">
  22. <div class="cbdboxs_table" v-loading="loading">
  23. <el-table
  24. :data="tableData"
  25. style="width: 100%"
  26. :stripe="true"
  27. :height="48 * 13"
  28. >
  29. <el-table-column prop="index" label="序号"> </el-table-column>
  30. <el-table-column
  31. prop="inducer_name"
  32. label="引诱剂名称"
  33. ></el-table-column>
  34. <!-- <el-table-column prop="expire" label="引诱剂有效天数">
  35. </el-table-column> -->
  36. <el-table-column prop="messages" label="描述"> </el-table-column>
  37. <el-table-column label="操作" width="300">
  38. <template slot-scope="scope">
  39. <span
  40. style="color: #409eff; margin-right: 5px; cursor: pointer;"
  41. @click="alter(scope.row)"
  42. >编辑</span
  43. >
  44. <span
  45. style="color: #409eff; margin-right: 5px; cursor: pointer;"
  46. @click="deletes(scope.row)"
  47. >删除</span
  48. >
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. </div>
  53. <el-pagination
  54. background
  55. layout="prev, pager, next,jumper"
  56. :total="total"
  57. :page-size="20"
  58. @current-change="pageChange"
  59. >
  60. </el-pagination>
  61. </el-card>
  62. <el-dialog
  63. :title="addtitle"
  64. :visible.sync="addtraptf"
  65. width="30%"
  66. @close="resetForm('ruleForm')"
  67. >
  68. <div>
  69. <el-form
  70. :model="ruleForm"
  71. :rules="rules"
  72. ref="ruleForm"
  73. label-width="100px"
  74. class="demo-ruleForm"
  75. >
  76. <el-form-item label="诱剂名称" prop="inducer_name">
  77. <el-input type="text" v-model="ruleForm.inducer_name"></el-input>
  78. </el-form-item>
  79. <!-- <el-form-item label="有效期天数" prop="expire">
  80. <el-input v-model="ruleForm.expire"></el-input>
  81. </el-form-item> -->
  82. <el-form-item label="诱剂描述" prop="messages">
  83. <el-input type="textarea" v-model="ruleForm.messages"></el-input>
  84. </el-form-item>
  85. </el-form>
  86. </div>
  87. <span slot="footer" class="dialog-footer">
  88. <el-button @click="resetForm('ruleForm')" size="mini">取 消</el-button>
  89. <el-button type="primary" @click="submitForm('ruleForm')" size="mini"
  90. :disabled="releaseTF"
  91. >{{ releaseTF ? "发布中..." : "确 定" }}</el-button
  92. >
  93. </span>
  94. </el-dialog>
  95. </div>
  96. </template>
  97. <script>
  98. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  99. export default {
  100. //import引入的组件需要注入到对象中才能使用
  101. components: {},
  102. data() {
  103. //这里存放数据
  104. var checklnglat = (rule, value, callback) => {
  105. if (isNaN(value)) {
  106. callback(new Error("请输入数字值"));
  107. } else {
  108. callback();
  109. }
  110. };
  111. return {
  112. tableData: [],
  113. queryInfo: {
  114. page: 1,
  115. inducer_name: "",
  116. },
  117. total: 10,
  118. loading: false,
  119. //新增诱剂
  120. addtraptf: false, //弹框开关
  121. ruleForm: {
  122. //验证
  123. inducer_name: "",
  124. expire: "",
  125. messages: "",
  126. inducer_id: "",
  127. },
  128. rules: {
  129. inducer_name: [
  130. { required: true, message: "请输入活动名称", trigger: "blur" },
  131. ],
  132. expire: [
  133. { required: true, message: "请输入活动名称", trigger: "blur" },
  134. { validator: checklnglat, trigger: "blur" },
  135. ],
  136. messages: [
  137. { required: true, message: "请输入活动名称", trigger: "blur" },
  138. ],
  139. },
  140. addtitle: "新增诱剂",
  141. releaseTF:false
  142. };
  143. },
  144. //监听属性 类似于data概念
  145. computed: {},
  146. //监控data中的数据变化
  147. watch: {},
  148. //方法集合
  149. methods: {
  150. getcbdlist() {
  151. //获取设备列表
  152. this.loading = true;
  153. this.$axios({
  154. method: "POST",
  155. url: "/api/api_gateway?method=monitor_manage.maintain.inducer_list",
  156. data: this.qs.stringify({
  157. page_size: 20,
  158. page: this.queryInfo.page,
  159. inducer_name: this.queryInfo.inducer_name, // 非必传(string) 诱剂名称 搜索项
  160. }),
  161. }).then((res) => {
  162. this.loading = false;
  163. console.log(res.data.data);
  164. this.total = res.data.data.total_item;
  165. this.tableData = res.data.data.page_list;
  166. for (var i = 0; i < this.tableData.length; i++) {
  167. this.tableData[i]["index"] = i + 1;
  168. }
  169. });
  170. },
  171. search() {
  172. this.getcbdlist();
  173. },
  174. pageChange(e) {
  175. // console.log(e)
  176. this.queryInfo.page = e;
  177. this.getcbdlist();
  178. },
  179. alter(events) {
  180. this.addtitle = "修改诱剂";
  181. this.addtraptf = true;
  182. for (var key in this.ruleForm) {
  183. this.ruleForm[key] = events[key];
  184. }
  185. // console.log(this.ruleForm)
  186. }, //修改
  187. deletes(events) {
  188. //删除
  189. //删除诱捕器
  190. console.log(events);
  191. var str = "您确定删除<" + events.inducer_name + ">吗?";
  192. this.$confirm(str, "删除诱剂", {
  193. confirmButtonText: "确定",
  194. cancelButtonText: "取消",
  195. })
  196. .then(() => {
  197. this.$axios({
  198. method: "POST",
  199. url: "/api/api_gateway?method=monitor_manage.maintain.inducer_delete",
  200. data: this.qs.stringify({
  201. inducer_id: events.inducer_id,
  202. }),
  203. }).then((res) => {
  204. console.log(res);
  205. if (res.data.data) {
  206. this.$message({
  207. showClose: true,
  208. message: "删除成功!",
  209. type: "success",
  210. });
  211. this.getcbdlist();
  212. } else {
  213. this.$message({
  214. showClose: true,
  215. message: "删除失败," + res.data.message,
  216. type: "warning",
  217. });
  218. }
  219. });
  220. })
  221. .catch(() => {
  222. this.$message({
  223. type: "info",
  224. message: "已取消删除",
  225. });
  226. });
  227. },
  228. submitForm(formName) {
  229. console.log(this.ruleForm);
  230. this.$refs[formName].validate((valid) => {
  231. if (valid) {
  232. if (this.addtitle == "修改诱剂") {
  233. this.releaseTF = true
  234. this.$axios({
  235. method: "POST",
  236. url: "/api/api_gateway?method=monitor_manage.maintain.inducer_modify",
  237. data: this.qs.stringify({
  238. inducer_id: this.ruleForm.inducer_id,
  239. inducer_name: this.ruleForm.inducer_name,
  240. expire: Number(this.ruleForm.expire),
  241. messages: this.ruleForm.messages,
  242. }),
  243. }).then((res) => {
  244. console.log(res);
  245. if (res.data.data) {
  246. this.$message({
  247. showClose: true,
  248. message: "修改成功!",
  249. type: "success",
  250. });
  251. this.addtraptf = false;
  252. this.getcbdlist();
  253. this.$refs[formName].resetFields();
  254. } else {
  255. this.$message({
  256. showClose: true,
  257. message: "修改失败" + res.data.message,
  258. type: "warning",
  259. });
  260. }
  261. this.releaseTF = false
  262. });
  263. } else if (this.addtitle == "新增诱剂") {
  264. this.releaseTF = true
  265. this.$axios({
  266. method: "POST",
  267. url: "/api/api_gateway?method=monitor_manage.maintain.inducer_add",
  268. data: this.qs.stringify({
  269. inducer_name: this.ruleForm.inducer_name,
  270. expire: this.ruleForm.expire,
  271. messages: this.ruleForm.messages,
  272. }),
  273. }).then((res) => {
  274. console.log(res);
  275. if (res.data.data) {
  276. this.$message({
  277. showClose: true,
  278. message: "新增成功!",
  279. type: "success",
  280. });
  281. this.addtraptf = false;
  282. this.getcbdlist();
  283. this.$refs[formName].resetFields();
  284. } else {
  285. this.$message({
  286. showClose: true,
  287. message: "添加失败" + res.data.message,
  288. type: "warning",
  289. });
  290. }
  291. this.releaseTF = false
  292. });
  293. }
  294. } else {
  295. // console.log("error submit!!");
  296. // this.$refs[formName].resetFields();
  297. return false;
  298. }
  299. });
  300. },
  301. resetForm(formName) {
  302. this.addtraptf = false;
  303. this.$refs[formName].resetFields();
  304. for (var key in this.ruleForm) {
  305. this.ruleForm[key] = "";
  306. }
  307. },
  308. dioclose() {
  309. console.log(111);
  310. // this.$refs[formName].resetFields();
  311. },
  312. },
  313. beforeCreate() {}, //生命周期 - 创建之前
  314. //生命周期 - 创建完成(可以访问当前this实例)
  315. created() {},
  316. beforeMount() {}, //生命周期 - 挂载之前
  317. //生命周期 - 挂载完成(可以访问DOM元素)
  318. mounted() {
  319. this.getcbdlist();
  320. },
  321. beforeUpdate() {}, //生命周期 - 更新之前
  322. updated() {}, //生命周期 - 更新之后
  323. beforeDestroy() {}, //生命周期 - 销毁之前
  324. destroyed() {}, //生命周期 - 销毁完成
  325. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  326. };
  327. </script>
  328. <style scoped lang="less">
  329. .cbdboxs_search {
  330. display: flex;
  331. justify-content: flex-start;
  332. // height: 40px;
  333. /deep/.el-select {
  334. width: 220px;
  335. margin-right: 15px;
  336. }
  337. /deep/.el-input {
  338. width: 220px;
  339. margin-right: 15px;
  340. }
  341. /deep/.el-date-editor {
  342. width: 250px !important;
  343. margin-right: 15px;
  344. }
  345. }
  346. .cbdboxs_table {
  347. /deep/.el-table__header-wrapper {
  348. th {
  349. background-color: #fafafa;
  350. }
  351. }
  352. }
  353. /deep/.el-button--info {
  354. background-color: #409eff;
  355. border-color: #409eff;
  356. }
  357. // 文本域样式更改
  358. /deep/.el-textarea__inner {
  359. font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
  360. }
  361. </style>