index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="姓名" prop="fullName">
  5. <el-input
  6. v-model="queryParams.fullName"
  7. placeholder="请输入姓名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="手机号" prop="phone">
  14. <el-input
  15. v-model="queryParams.phone"
  16. placeholder="请输入手机号"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="绑定时间" prop="bindDate">
  23. <el-date-picker clearable size="small" style="width: 200px"
  24. v-model="queryParams.bindDate"
  25. type="date"
  26. value-format="yyyy-MM-dd"
  27. placeholder="选择绑定时间">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="绑定状态" prop="bindStatus">
  31. <el-select v-model="queryParams.bindStatus" placeholder="请选择绑定状态" clearable size="small">
  32. <el-option label="请选择字典生成" value="" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="微信昵称" prop="wxFullName">
  36. <el-input
  37. v-model="queryParams.wxFullName"
  38. placeholder="请输入微信昵称"
  39. clearable
  40. size="small"
  41. @keyup.enter.native="handleQuery"
  42. />
  43. </el-form-item>
  44. <el-form-item label="油站id" prop="stationId">
  45. <el-input
  46. v-model="queryParams.stationId"
  47. placeholder="请输入油站id"
  48. clearable
  49. size="small"
  50. @keyup.enter.native="handleQuery"
  51. />
  52. </el-form-item>
  53. <el-form-item label="油站名称" prop="stationName">
  54. <el-input
  55. v-model="queryParams.stationName"
  56. placeholder="请输入油站名称"
  57. clearable
  58. size="small"
  59. @keyup.enter.native="handleQuery"
  60. />
  61. </el-form-item>
  62. <el-form-item>
  63. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  64. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <el-col :span="1.5">
  69. <el-button
  70. type="primary"
  71. icon="el-icon-plus"
  72. size="mini"
  73. @click="handleAdd"
  74. v-hasPermi="['station:notice:add']"
  75. >新增</el-button>
  76. </el-col>
  77. <el-col :span="1.5">
  78. <el-button
  79. type="success"
  80. icon="el-icon-edit"
  81. size="mini"
  82. :disabled="single"
  83. @click="handleUpdate"
  84. v-hasPermi="['station:notice:edit']"
  85. >修改</el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. type="danger"
  90. icon="el-icon-delete"
  91. size="mini"
  92. :disabled="multiple"
  93. @click="handleDelete"
  94. v-hasPermi="['station:notice:remove']"
  95. >删除</el-button>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-button
  99. type="warning"
  100. icon="el-icon-download"
  101. size="mini"
  102. @click="handleExport"
  103. v-hasPermi="['station:notice:export']"
  104. >导出</el-button>
  105. </el-col>
  106. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  107. </el-row>
  108. <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
  109. <el-table-column type="selection" width="55" align="center" />
  110. <el-table-column label="通知id 自增主键id" align="center" prop="noticeId" />
  111. <el-table-column label="姓名" align="center" prop="fullName" />
  112. <el-table-column label="手机号" align="center" prop="phone" />
  113. <el-table-column label="绑定时间" align="center" prop="bindDate" width="180">
  114. <template slot-scope="scope">
  115. <span>{{ parseTime(scope.row.bindDate, '{y}-{m}-{d}') }}</span>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="绑定状态" align="center" prop="bindStatus" />
  119. <el-table-column label="微信昵称" align="center" prop="wxFullName" />
  120. <el-table-column label="油站id" align="center" prop="stationId" />
  121. <el-table-column label="油站名称" align="center" prop="stationName" />
  122. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  123. <template slot-scope="scope">
  124. <el-button
  125. size="mini"
  126. type="text"
  127. icon="el-icon-edit"
  128. @click="handleUpdate(scope.row)"
  129. v-hasPermi="['station:notice:edit']"
  130. >修改</el-button>
  131. <el-button
  132. size="mini"
  133. type="text"
  134. icon="el-icon-delete"
  135. @click="handleDelete(scope.row)"
  136. v-hasPermi="['station:notice:remove']"
  137. >删除</el-button>
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. <pagination
  142. v-show="total>0"
  143. :total="total"
  144. :page.sync="queryParams.pageNum"
  145. :limit.sync="queryParams.pageSize"
  146. @pagination="getList"
  147. />
  148. <!-- 添加或修改油站通知管理对话框 -->
  149. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  150. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  151. <el-form-item label="姓名" prop="fullName">
  152. <el-input v-model="form.fullName" placeholder="请输入姓名" />
  153. </el-form-item>
  154. <el-form-item label="手机号" prop="phone">
  155. <el-input v-model="form.phone" placeholder="请输入手机号" />
  156. </el-form-item>
  157. <el-form-item label="绑定时间" prop="bindDate">
  158. <el-date-picker clearable size="small" style="width: 200px"
  159. v-model="form.bindDate"
  160. type="date"
  161. value-format="yyyy-MM-dd"
  162. placeholder="选择绑定时间">
  163. </el-date-picker>
  164. </el-form-item>
  165. <el-form-item label="绑定状态">
  166. <el-radio-group v-model="form.bindStatus">
  167. <el-radio label="1">请选择字典生成</el-radio>
  168. </el-radio-group>
  169. </el-form-item>
  170. <el-form-item label="微信昵称" prop="wxFullName">
  171. <el-input v-model="form.wxFullName" placeholder="请输入微信昵称" />
  172. </el-form-item>
  173. <el-form-item label="油站id" prop="stationId">
  174. <el-input v-model="form.stationId" placeholder="请输入油站id" />
  175. </el-form-item>
  176. <el-form-item label="油站名称" prop="stationName">
  177. <el-input v-model="form.stationName" placeholder="请输入油站名称" />
  178. </el-form-item>
  179. </el-form>
  180. <div slot="footer" class="dialog-footer">
  181. <el-button type="primary" @click="submitForm">确 定</el-button>
  182. <el-button @click="cancel">取 消</el-button>
  183. </div>
  184. </el-dialog>
  185. </div>
  186. </template>
  187. <script>
  188. import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice } from "@/api/station/notice";
  189. export default {
  190. name: "Notice",
  191. data() {
  192. return {
  193. // 遮罩层
  194. loading: true,
  195. // 选中数组
  196. ids: [],
  197. // 非单个禁用
  198. single: true,
  199. // 非多个禁用
  200. multiple: true,
  201. // 显示搜索条件
  202. showSearch: true,
  203. // 总条数
  204. total: 0,
  205. // 油站通知管理表格数据
  206. noticeList: [],
  207. // 弹出层标题
  208. title: "",
  209. // 是否显示弹出层
  210. open: false,
  211. // 查询参数
  212. queryParams: {
  213. pageNum: 1,
  214. pageSize: 10,
  215. fullName: null,
  216. phone: null,
  217. bindDate: null,
  218. bindStatus: null,
  219. wxFullName: null,
  220. stationId: null,
  221. stationName: null
  222. },
  223. // 表单参数
  224. form: {},
  225. // 表单校验
  226. rules: {
  227. }
  228. };
  229. },
  230. created() {
  231. this.getList();
  232. },
  233. methods: {
  234. /** 查询油站通知管理列表 */
  235. getList() {
  236. this.loading = true;
  237. listNotice(this.queryParams).then(response => {
  238. this.noticeList = response.rows;
  239. this.total = response.total;
  240. this.loading = false;
  241. });
  242. },
  243. // 取消按钮
  244. cancel() {
  245. this.open = false;
  246. this.reset();
  247. },
  248. // 表单重置
  249. reset() {
  250. this.form = {
  251. noticeId: null,
  252. fullName: null,
  253. phone: null,
  254. bindDate: null,
  255. bindStatus: "0",
  256. wxFullName: null,
  257. stationId: null,
  258. stationName: null
  259. };
  260. this.resetForm("form");
  261. },
  262. /** 搜索按钮操作 */
  263. handleQuery() {
  264. this.queryParams.pageNum = 1;
  265. this.getList();
  266. },
  267. /** 重置按钮操作 */
  268. resetQuery() {
  269. this.resetForm("queryForm");
  270. this.handleQuery();
  271. },
  272. // 多选框选中数据
  273. handleSelectionChange(selection) {
  274. this.ids = selection.map(item => item.noticeId)
  275. this.single = selection.length!==1
  276. this.multiple = !selection.length
  277. },
  278. /** 新增按钮操作 */
  279. handleAdd() {
  280. this.reset();
  281. this.open = true;
  282. this.title = "添加油站通知管理";
  283. },
  284. /** 修改按钮操作 */
  285. handleUpdate(row) {
  286. this.reset();
  287. const noticeId = row.noticeId || this.ids
  288. getNotice(noticeId).then(response => {
  289. this.form = response.data;
  290. this.open = true;
  291. this.title = "修改油站通知管理";
  292. });
  293. },
  294. /** 提交按钮 */
  295. submitForm() {
  296. this.$refs["form"].validate(valid => {
  297. if (valid) {
  298. if (this.form.noticeId != null) {
  299. updateNotice(this.form).then(response => {
  300. this.msgSuccess("修改成功");
  301. this.open = false;
  302. this.getList();
  303. });
  304. } else {
  305. addNotice(this.form).then(response => {
  306. this.msgSuccess("新增成功");
  307. this.open = false;
  308. this.getList();
  309. });
  310. }
  311. }
  312. });
  313. },
  314. /** 删除按钮操作 */
  315. handleDelete(row) {
  316. const noticeIds = row.noticeId || this.ids;
  317. this.$confirm('是否确认删除油站通知管理编号为"' + noticeIds + '"的数据项?', "警告", {
  318. confirmButtonText: "确定",
  319. cancelButtonText: "取消",
  320. type: "warning"
  321. }).then(function() {
  322. return delNotice(noticeIds);
  323. }).then(() => {
  324. this.getList();
  325. this.msgSuccess("删除成功");
  326. })
  327. },
  328. /** 导出按钮操作 */
  329. handleExport() {
  330. const queryParams = this.queryParams;
  331. this.$confirm('是否确认导出所有油站通知管理数据项?', "警告", {
  332. confirmButtonText: "确定",
  333. cancelButtonText: "取消",
  334. type: "warning"
  335. }).then(function() {
  336. return exportNotice(queryParams);
  337. }).then(response => {
  338. this.download(response.msg);
  339. })
  340. }
  341. }
  342. };
  343. </script>