index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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="merchantAccount">
  5. <el-input v-model="queryParams.merchantAccount" placeholder="请输入商户号" clearable size="small"
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="商户名称" prop="merchantName">
  9. <el-input v-model="queryParams.merchantName" placeholder="请输入商户名称" clearable size="small"
  10. @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item label="分账类型" prop="type">
  13. <el-select v-model="queryParams.type" placeholder="请选择分账类型" clearable size="small">
  14. <el-option label="聚水潭" value="1" />
  15. <el-option label="兔灵" value="2" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  20. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <el-row :gutter="10" class="mb8">
  24. <el-col :span="1.5">
  25. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  26. v-hasPermi="['his:merchant:add']">新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  30. v-hasPermi="['his:merchant:edit']">修改</el-button>
  31. </el-col>
  32. <el-col :span="1.5">
  33. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  34. v-hasPermi="['his:merchant:remove']">删除</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading"
  38. @click="handleExport" v-hasPermi="['his:merchant:export']">导出</el-button>
  39. </el-col>
  40. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  41. </el-row>
  42. <el-table border v-loading="loading" :data="merchantList" @selection-change="handleSelectionChange">
  43. <el-table-column type="selection" width="55" align="center" />
  44. <el-table-column label="id" align="center" prop="id" />
  45. <el-table-column label="商户号" align="center" prop="merchantAccount" />
  46. <el-table-column label="商户名称" align="center" prop="merchantName" />
  47. <el-table-column label="分账类型" align="center" prop="type" >
  48. <template slot-scope="scope">
  49. <dict-tag :options="erpTypeOptions" :value="scope.row.type"/>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  53. <template slot-scope="scope">
  54. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  55. v-hasPermi="['his:merchant:edit']">修改</el-button>
  56. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  57. v-hasPermi="['his:merchant:remove']">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  62. @pagination="getList" />
  63. <!-- 添加或修改分账商户对话框 -->
  64. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  65. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  66. <el-form-item label="商户号" prop="merchantAccount">
  67. <el-input v-model="form.merchantAccount" placeholder="请输入商户号" />
  68. </el-form-item>
  69. <el-form-item label="商户名称" prop="merchantName">
  70. <el-input v-model="form.merchantName" placeholder="请输入商户名称" />
  71. </el-form-item>
  72. <el-form-item label="分账类型" prop="type">
  73. <el-radio-group v-model="form.type">
  74. <el-radio :label="parseInt(item.dictValue)" v-for="item in erpTypeOptions">{{ item.dictLabel }}</el-radio>
  75. </el-radio-group>
  76. </el-form-item>
  77. </el-form>
  78. <div slot="footer" class="dialog-footer">
  79. <el-button type="primary" @click="submitForm">确 定</el-button>
  80. <el-button @click="cancel">取 消</el-button>
  81. </div>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import { listMerchant, getMerchant, delMerchant, addMerchant, updateMerchant, exportMerchant } from "@/api/his/merchant";
  87. export default {
  88. name: "Merchant",
  89. data() {
  90. return {
  91. // 遮罩层
  92. loading: true,
  93. // 导出遮罩层
  94. exportLoading: false,
  95. // 选中数组
  96. ids: [],
  97. // 非单个禁用
  98. single: true,
  99. // 非多个禁用
  100. multiple: true,
  101. // 显示搜索条件
  102. showSearch: true,
  103. // 总条数
  104. total: 0,
  105. // 分账商户表格数据
  106. merchantList: [],
  107. // 弹出层标题
  108. title: "",
  109. // 是否显示弹出层
  110. open: false,
  111. // 查询参数
  112. queryParams: {
  113. pageNum: 1,
  114. pageSize: 10,
  115. merchantAccount: null,
  116. merchantName: null,
  117. type: null,
  118. },
  119. // 表单参数
  120. form: {},
  121. // 表单校验
  122. rules: {
  123. merchantAccount: [
  124. { required: true, message: '套餐包名称不能为空', trigger: 'blur' }
  125. ],
  126. merchantName: [
  127. { required: true, message: '套餐包名称不能为空', trigger: 'blur' }
  128. ],
  129. type: [
  130. { required: true, message: '请选择分账类型', trigger: 'change' }
  131. ],
  132. },
  133. erpTypeOptions: []
  134. };
  135. },
  136. created() {
  137. this.getDicts("sys_erp_type").then(response => {
  138. this.erpTypeOptions = response.data;
  139. });
  140. this.getList();
  141. },
  142. methods: {
  143. /** 查询分账商户列表 */
  144. getList() {
  145. this.loading = true;
  146. listMerchant(this.queryParams).then(response => {
  147. this.merchantList = response.rows;
  148. this.total = response.total;
  149. this.loading = false;
  150. });
  151. },
  152. // 取消按钮
  153. cancel() {
  154. this.open = false;
  155. this.reset();
  156. },
  157. // 表单重置
  158. reset() {
  159. this.form = {
  160. id: null,
  161. merchantAccount: null,
  162. merchantName: null,
  163. type: null,
  164. createTime: null,
  165. updateTime: null
  166. };
  167. this.resetForm("form");
  168. },
  169. /** 搜索按钮操作 */
  170. handleQuery() {
  171. this.queryParams.pageNum = 1;
  172. this.getList();
  173. },
  174. /** 重置按钮操作 */
  175. resetQuery() {
  176. this.resetForm("queryForm");
  177. this.handleQuery();
  178. },
  179. // 多选框选中数据
  180. handleSelectionChange(selection) {
  181. this.ids = selection.map(item => item.id)
  182. this.single = selection.length !== 1
  183. this.multiple = !selection.length
  184. },
  185. /** 新增按钮操作 */
  186. handleAdd() {
  187. this.reset();
  188. this.open = true;
  189. this.title = "添加分账商户";
  190. },
  191. /** 修改按钮操作 */
  192. handleUpdate(row) {
  193. this.reset();
  194. const id = row.id || this.ids
  195. getMerchant(id).then(response => {
  196. this.form = response.data;
  197. this.open = true;
  198. this.title = "修改分账商户";
  199. });
  200. },
  201. /** 提交按钮 */
  202. submitForm() {
  203. this.$refs["form"].validate(valid => {
  204. if (valid) {
  205. if (this.form.id != null) {
  206. updateMerchant(this.form).then(response => {
  207. this.msgSuccess("修改成功");
  208. this.open = false;
  209. this.getList();
  210. });
  211. } else {
  212. addMerchant(this.form).then(response => {
  213. this.msgSuccess("新增成功");
  214. this.open = false;
  215. this.getList();
  216. });
  217. }
  218. }
  219. });
  220. },
  221. /** 删除按钮操作 */
  222. handleDelete(row) {
  223. const ids = row.id || this.ids;
  224. this.$confirm('是否确认删除分账商户编号为"' + ids + '"的数据项?', "警告", {
  225. confirmButtonText: "确定",
  226. cancelButtonText: "取消",
  227. type: "warning"
  228. }).then(function () {
  229. return delMerchant(ids);
  230. }).then(() => {
  231. this.getList();
  232. this.msgSuccess("删除成功");
  233. }).catch(() => { });
  234. },
  235. /** 导出按钮操作 */
  236. handleExport() {
  237. const queryParams = this.queryParams;
  238. this.$confirm('是否确认导出所有分账商户数据项?', "警告", {
  239. confirmButtonText: "确定",
  240. cancelButtonText: "取消",
  241. type: "warning"
  242. }).then(() => {
  243. this.exportLoading = true;
  244. return exportMerchant(queryParams);
  245. }).then(response => {
  246. this.download(response.msg);
  247. this.exportLoading = false;
  248. }).catch(() => { });
  249. }
  250. }
  251. };
  252. </script>