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.

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