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.

313 lines
9.8 KiB

2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="商户名称" prop="title">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入商户名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['muhu:guide:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. plain
  32. icon="el-icon-edit"
  33. size="mini"
  34. :disabled="single"
  35. @click="handleUpdate"
  36. v-hasPermi="['muhu:guide:edit']"
  37. >修改</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="el-icon-delete"
  44. size="mini"
  45. :disabled="multiple"
  46. @click="handleDelete"
  47. v-hasPermi="['muhu:guide:remove']"
  48. >删除</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. @click="handleExport"
  57. v-hasPermi="['muhu:guide:export']"
  58. >导出</el-button>
  59. </el-col>
  60. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  61. </el-row>
  62. <el-table v-loading="loading" :data="guideList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="图标" align="center" prop="iconPath" width="100">
  65. <template slot-scope="scope">
  66. <image-preview :src="scope.row.iconPath" :width="50" :height="50" />
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="商户名称" align="center" prop="title" />
  70. <el-table-column label="商户类型" align="center" prop="guideType">
  71. <template slot-scope="scope">
  72. <dict-tag :options="dict.type.guide_type" :value="scope.row.guideType" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="联系人" align="center" prop="name" />
  76. <el-table-column label="联系方式" align="center" prop="iphone" />
  77. <el-table-column label="所在区域" align="center" prop="region" />
  78. <el-table-column label="详细地址" align="center" prop="address" />
  79. <el-table-column label="纬度" align="center" prop="latitude" />
  80. <el-table-column label="经度" align="center" prop="longitude" />
  81. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  82. <template slot-scope="scope">
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-edit"
  87. @click="handleUpdate(scope.row)"
  88. v-hasPermi="['muhu:guide:edit']"
  89. >修改</el-button>
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-delete"
  94. @click="handleDelete(scope.row)"
  95. v-hasPermi="['muhu:guide:remove']"
  96. >删除</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination
  101. v-show="total>0"
  102. :total="total"
  103. :page.sync="queryParams.pageNum"
  104. :limit.sync="queryParams.pageSize"
  105. @pagination="getList"
  106. />
  107. <!-- 添加或修改办事指南对话框 -->
  108. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  109. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  110. <el-form-item label="商户类型" prop="guideType">
  111. <el-select v-model="form.guideType" placeholder="请选择商户类型" clearable>
  112. <el-option v-for="dict in dict.type.guide_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  113. </el-select>
  114. </el-form-item>
  115. <el-form-item label="商户名称" prop="title">
  116. <el-input v-model="form.title" placeholder="请输入商户名称" />
  117. </el-form-item>
  118. <el-form-item label="联系人" prop="title">
  119. <el-input v-model="form.name" placeholder="请输入联系人" />
  120. </el-form-item>
  121. <el-form-item label="联系方式" prop="title">
  122. <el-input v-model="form.iphone" placeholder="请输入联系方式" />
  123. </el-form-item>
  124. <el-form-item label="所在区域" prop="region">
  125. <el-input v-model="form.region" placeholder="请输入所在区域" />
  126. </el-form-item>
  127. <el-form-item label="详细地址" prop="address">
  128. <el-input v-model="form.address" placeholder="请输入详细地址" />
  129. </el-form-item>
  130. <el-form-item label="纬度" prop="latitude">
  131. <el-input v-model="form.latitude" placeholder="请输入纬度" />
  132. </el-form-item>
  133. <el-form-item label="经度" prop="longitude">
  134. <el-input v-model="form.longitude" placeholder="请输入经度" />
  135. </el-form-item>
  136. <el-form-item label="图标" prop="iconPath">
  137. <image-upload v-model="form.iconPath" />
  138. </el-form-item>
  139. </el-form>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button type="primary" @click="submitForm"> </el-button>
  142. <el-button @click="cancel"> </el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { listGuide, getGuide, delGuide, addGuide, updateGuide } from "@/api/muhu/guide"
  149. export default {
  150. name: "Guide",
  151. dicts: ['guide_type'],
  152. data() {
  153. return {
  154. // 遮罩层
  155. loading: true,
  156. // 选中数组
  157. ids: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 办事指南表格数据
  167. guideList: [],
  168. // 弹出层标题
  169. title: "",
  170. // 是否显示弹出层
  171. open: false,
  172. // 查询参数
  173. queryParams: {
  174. pageNum: 1,
  175. pageSize: 10,
  176. iconPath: null,
  177. title: null,
  178. guideType: null,
  179. merchantSubtype: null,
  180. region: null,
  181. address: null,
  182. latitude: null,
  183. longitude: null
  184. },
  185. // 表单参数
  186. form: {},
  187. // 表单校验
  188. rules: {
  189. title: [
  190. { required: true, message: "商户名称不能为空", trigger: "blur" }
  191. ],
  192. guideType: [
  193. { required: true, message: "商户类型不能为空", trigger: "change" }
  194. ],
  195. region: [
  196. { required: true, message: "所在区域不能为空", trigger: "blur" }
  197. ],
  198. address: [
  199. { required: true, message: "详细地址不能为空", trigger: "blur" }
  200. ],
  201. }
  202. }
  203. },
  204. created() {
  205. this.getList()
  206. },
  207. methods: {
  208. /** 查询办事指南列表 */
  209. getList() {
  210. this.loading = true
  211. listGuide(this.queryParams).then(response => {
  212. this.guideList = response.rows
  213. this.total = response.total
  214. this.loading = false
  215. })
  216. },
  217. // 取消按钮
  218. cancel() {
  219. this.open = false
  220. this.reset()
  221. },
  222. // 表单重置
  223. reset() {
  224. this.form = {
  225. id: null,
  226. iconPath: null,
  227. title: null,
  228. guideType: null,
  229. merchantSubtype: null,
  230. region: null,
  231. address: null,
  232. latitude: null,
  233. longitude: null
  234. }
  235. this.resetForm("form")
  236. },
  237. /** 搜索按钮操作 */
  238. handleQuery() {
  239. this.queryParams.pageNum = 1
  240. this.getList()
  241. },
  242. /** 重置按钮操作 */
  243. resetQuery() {
  244. this.resetForm("queryForm")
  245. this.handleQuery()
  246. },
  247. // 多选框选中数据
  248. handleSelectionChange(selection) {
  249. this.ids = selection.map(item => item.id)
  250. this.single = selection.length!==1
  251. this.multiple = !selection.length
  252. },
  253. /** 新增按钮操作 */
  254. handleAdd() {
  255. this.reset()
  256. this.open = true
  257. this.title = "添加办事指南"
  258. },
  259. /** 修改按钮操作 */
  260. handleUpdate(row) {
  261. this.reset()
  262. const id = row.id || this.ids
  263. getGuide(id).then(response => {
  264. this.form = response.data
  265. this.open = true
  266. this.title = "修改办事指南"
  267. })
  268. },
  269. /** 提交按钮 */
  270. submitForm() {
  271. this.$refs["form"].validate(valid => {
  272. if (valid) {
  273. if (this.form.id != null) {
  274. updateGuide(this.form).then(response => {
  275. this.$modal.msgSuccess("修改成功")
  276. this.open = false
  277. this.getList()
  278. })
  279. } else {
  280. addGuide(this.form).then(response => {
  281. this.$modal.msgSuccess("新增成功")
  282. this.open = false
  283. this.getList()
  284. })
  285. }
  286. }
  287. })
  288. },
  289. /** 删除按钮操作 */
  290. handleDelete(row) {
  291. const ids = row.id || this.ids
  292. this.$modal.confirm('是否确认删除办事指南编号为"' + ids + '"的数据项?').then(function() {
  293. return delGuide(ids)
  294. }).then(() => {
  295. this.getList()
  296. this.$modal.msgSuccess("删除成功")
  297. }).catch(() => {})
  298. },
  299. /** 导出按钮操作 */
  300. handleExport() {
  301. this.download('muhu/guide/export', {
  302. ...this.queryParams
  303. }, `guide_${new Date().getTime()}.xlsx`)
  304. }
  305. }
  306. }
  307. </script>