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.

303 lines
9.3 KiB

  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:info: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:info: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:info: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:info: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="infoList" @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="merchantType">
  71. <template slot-scope="scope">
  72. <dict-tag :options="dict.type.merchant_type" :value="scope.row.merchantType" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="所在区域" align="center" prop="region" />
  76. <el-table-column label="详细地址" align="center" prop="address" />
  77. <el-table-column label="纬度" align="center" prop="latitude" />
  78. <el-table-column label="经度" align="center" prop="longitude" />
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-edit"
  85. @click="handleUpdate(scope.row)"
  86. v-hasPermi="['muhu:info:edit']"
  87. >修改</el-button>
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['muhu:info:remove']"
  94. >删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改商户地图信息对话框 -->
  106. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item label="商户类型" prop="merchantType">
  109. <el-select v-model="form.merchantType" placeholder="请选择商户类型" clearable>
  110. <el-option v-for="dict in dict.type.merchant_type" :key="dict.value" :label="dict.label" :value="dict.value" />
  111. </el-select>
  112. </el-form-item>
  113. <el-form-item label="商户名称" prop="title">
  114. <el-input v-model="form.title" placeholder="请输入商户名称" />
  115. </el-form-item>
  116. <el-form-item label="所在区域" prop="region">
  117. <el-input v-model="form.region" placeholder="请输入所在区域" />
  118. </el-form-item>
  119. <el-form-item label="详细地址" prop="address">
  120. <el-input v-model="form.address" placeholder="请输入详细地址" />
  121. </el-form-item>
  122. <el-form-item label="纬度" prop="latitude">
  123. <el-input v-model="form.latitude" placeholder="请输入纬度" />
  124. </el-form-item>
  125. <el-form-item label="经度" prop="longitude">
  126. <el-input v-model="form.longitude" placeholder="请输入经度" />
  127. </el-form-item>
  128. <el-form-item label="图标" prop="iconPath">
  129. <image-upload v-model="form.iconPath" />
  130. </el-form-item>
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="submitForm"> </el-button>
  134. <el-button @click="cancel"> </el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/muhu/info"
  141. export default {
  142. name: "Info",
  143. dicts: ['merchant_type'],
  144. data() {
  145. return {
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. // 非单个禁用
  151. single: true,
  152. // 非多个禁用
  153. multiple: true,
  154. // 显示搜索条件
  155. showSearch: true,
  156. // 总条数
  157. total: 0,
  158. // 商户地图信息表格数据
  159. infoList: [],
  160. // 弹出层标题
  161. title: "",
  162. // 是否显示弹出层
  163. open: false,
  164. // 查询参数
  165. queryParams: {
  166. pageNum: 1,
  167. pageSize: 10,
  168. title: null,
  169. merchantType: null,
  170. merchantSubtype: null,
  171. region: null,
  172. address: null,
  173. latitude: null,
  174. longitude: null
  175. },
  176. // 表单参数
  177. form: {},
  178. // 表单校验
  179. rules: {
  180. title: [
  181. { required: true, message: "商户名称不能为空", trigger: "blur" }
  182. ],
  183. merchantType: [
  184. { required: true, message: "商户类型不能为空", trigger: "change" }
  185. ],
  186. region: [
  187. { required: true, message: "所在区域不能为空", trigger: "blur" }
  188. ],
  189. address: [
  190. { required: true, message: "详细地址不能为空", trigger: "blur" }
  191. ],
  192. }
  193. }
  194. },
  195. created() {
  196. this.getList()
  197. },
  198. methods: {
  199. /** 查询商户地图信息列表 */
  200. getList() {
  201. this.loading = true
  202. listInfo(this.queryParams).then(response => {
  203. this.infoList = response.rows
  204. this.total = response.total
  205. this.loading = false
  206. })
  207. },
  208. // 取消按钮
  209. cancel() {
  210. this.open = false
  211. this.reset()
  212. },
  213. // 表单重置
  214. reset() {
  215. this.form = {
  216. id: null,
  217. title: null,
  218. merchantType: null,
  219. merchantSubtype: null,
  220. region: null,
  221. address: null,
  222. latitude: null,
  223. longitude: null
  224. }
  225. this.resetForm("form")
  226. },
  227. /** 搜索按钮操作 */
  228. handleQuery() {
  229. this.queryParams.pageNum = 1
  230. this.getList()
  231. },
  232. /** 重置按钮操作 */
  233. resetQuery() {
  234. this.resetForm("queryForm")
  235. this.handleQuery()
  236. },
  237. // 多选框选中数据
  238. handleSelectionChange(selection) {
  239. this.ids = selection.map(item => item.id)
  240. this.single = selection.length!==1
  241. this.multiple = !selection.length
  242. },
  243. /** 新增按钮操作 */
  244. handleAdd() {
  245. this.reset()
  246. this.open = true
  247. this.title = "添加商户地图信息"
  248. },
  249. /** 修改按钮操作 */
  250. handleUpdate(row) {
  251. this.reset()
  252. const id = row.id || this.ids
  253. getInfo(id).then(response => {
  254. this.form = response.data
  255. this.open = true
  256. this.title = "修改商户地图信息"
  257. })
  258. },
  259. /** 提交按钮 */
  260. submitForm() {
  261. this.$refs["form"].validate(valid => {
  262. if (valid) {
  263. if (this.form.id != null) {
  264. updateInfo(this.form).then(response => {
  265. this.$modal.msgSuccess("修改成功")
  266. this.open = false
  267. this.getList()
  268. })
  269. } else {
  270. addInfo(this.form).then(response => {
  271. this.$modal.msgSuccess("新增成功")
  272. this.open = false
  273. this.getList()
  274. })
  275. }
  276. }
  277. })
  278. },
  279. /** 删除按钮操作 */
  280. handleDelete(row) {
  281. const ids = row.id || this.ids
  282. this.$modal.confirm('是否确认删除商户地图信息编号为"' + ids + '"的数据项?').then(function() {
  283. return delInfo(ids)
  284. }).then(() => {
  285. this.getList()
  286. this.$modal.msgSuccess("删除成功")
  287. }).catch(() => {})
  288. },
  289. /** 导出按钮操作 */
  290. handleExport() {
  291. this.download('muhu/info/export', {
  292. ...this.queryParams
  293. }, `info_${new Date().getTime()}.xlsx`)
  294. }
  295. }
  296. }
  297. </script>