index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="省ID" prop="provinceId">
  5. <el-input
  6. v-model="queryParams.provinceId"
  7. placeholder="请输入省ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="模板ID" prop="tempId">
  14. <el-input
  15. v-model="queryParams.tempId"
  16. placeholder="请输入模板ID"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="城市ID" prop="cityId">
  23. <el-input
  24. v-model="queryParams.cityId"
  25. placeholder="请输入城市ID"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="首件" prop="first">
  32. <el-input
  33. v-model="queryParams.first"
  34. placeholder="请输入首件"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="首件运费" prop="firstPrice">
  41. <el-input
  42. v-model="queryParams.firstPrice"
  43. placeholder="请输入首件运费"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="续件" prop="continues">
  50. <el-input
  51. v-model="queryParams.continues"
  52. placeholder="请输入续件"
  53. clearable
  54. size="small"
  55. @keyup.enter.native="handleQuery"
  56. />
  57. </el-form-item>
  58. <el-form-item label="续件运费" prop="continuePrice">
  59. <el-input
  60. v-model="queryParams.continuePrice"
  61. placeholder="请输入续件运费"
  62. clearable
  63. size="small"
  64. @keyup.enter.native="handleQuery"
  65. />
  66. </el-form-item>
  67. <el-form-item label="计费方式" prop="type">
  68. <el-select v-model="queryParams.type" placeholder="请选择计费方式" clearable size="small">
  69. <el-option label="请选择字典生成" value="" />
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="分组唯一值" prop="productId">
  73. <el-input
  74. v-model="queryParams.productId"
  75. placeholder="请输入分组唯一值"
  76. clearable
  77. size="small"
  78. @keyup.enter.native="handleQuery"
  79. />
  80. </el-form-item>
  81. <el-form-item>
  82. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  83. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  84. </el-form-item>
  85. </el-form>
  86. <el-row :gutter="10" class="mb8">
  87. <el-col :span="1.5">
  88. <el-button
  89. type="primary"
  90. icon="el-icon-plus"
  91. size="mini"
  92. @click="handleAdd"
  93. v-hasPermi="['store:shippingTemplatesRegion:add']"
  94. >新增</el-button>
  95. </el-col>
  96. <el-col :span="1.5">
  97. <el-button
  98. type="success"
  99. icon="el-icon-edit"
  100. size="mini"
  101. :disabled="single"
  102. @click="handleUpdate"
  103. v-hasPermi="['store:shippingTemplatesRegion:edit']"
  104. >修改</el-button>
  105. </el-col>
  106. <el-col :span="1.5">
  107. <el-button
  108. type="danger"
  109. icon="el-icon-delete"
  110. size="mini"
  111. :disabled="multiple"
  112. @click="handleDelete"
  113. v-hasPermi="['store:shippingTemplatesRegion:remove']"
  114. >删除</el-button>
  115. </el-col>
  116. <el-col :span="1.5">
  117. <el-button
  118. type="warning"
  119. icon="el-icon-download"
  120. size="mini"
  121. @click="handleExport"
  122. v-hasPermi="['store:shippingTemplatesRegion:export']"
  123. >导出</el-button>
  124. </el-col>
  125. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  126. </el-row>
  127. <el-table v-loading="loading" :data="shippingTemplatesRegionList" @selection-change="handleSelectionChange" border>
  128. <el-table-column type="selection" width="55" align="center" />
  129. <el-table-column label="编号" align="center" prop="id" />
  130. <el-table-column label="省ID" align="center" prop="provinceId" />
  131. <el-table-column label="模板ID" align="center" prop="tempId" />
  132. <el-table-column label="城市ID" align="center" prop="cityId" />
  133. <el-table-column label="首件" align="center" prop="first" />
  134. <el-table-column label="首件运费" align="center" prop="firstPrice" />
  135. <el-table-column label="续件" align="center" prop="continues" />
  136. <el-table-column label="续件运费" align="center" prop="continuePrice" />
  137. <el-table-column label="计费方式" align="center" prop="type" />
  138. <el-table-column label="分组唯一值" align="center" prop="productId" />
  139. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  140. <template slot-scope="scope">
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-edit"
  145. @click="handleUpdate(scope.row)"
  146. v-hasPermi="['store:shippingTemplatesRegion:edit']"
  147. >修改</el-button>
  148. <el-button
  149. size="mini"
  150. type="text"
  151. icon="el-icon-delete"
  152. @click="handleDelete(scope.row)"
  153. v-hasPermi="['store:shippingTemplatesRegion:remove']"
  154. >删除</el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination
  159. v-show="total>0"
  160. :total="total"
  161. :page.sync="queryParams.pageNum"
  162. :limit.sync="queryParams.pageSize"
  163. @pagination="getList"
  164. />
  165. <!-- 添加或修改邮费区域对话框 -->
  166. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  167. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  168. <el-form-item label="省ID" prop="provinceId">
  169. <el-input v-model="form.provinceId" placeholder="请输入省ID" />
  170. </el-form-item>
  171. <el-form-item label="模板ID" prop="tempId">
  172. <el-input v-model="form.tempId" placeholder="请输入模板ID" />
  173. </el-form-item>
  174. <el-form-item label="城市ID" prop="cityId">
  175. <el-input v-model="form.cityId" placeholder="请输入城市ID" />
  176. </el-form-item>
  177. <el-form-item label="首件" prop="first">
  178. <el-input v-model="form.first" placeholder="请输入首件" />
  179. </el-form-item>
  180. <el-form-item label="首件运费" prop="firstPrice">
  181. <el-input v-model="form.firstPrice" placeholder="请输入首件运费" />
  182. </el-form-item>
  183. <el-form-item label="续件" prop="continues">
  184. <el-input v-model="form.continues" placeholder="请输入续件" />
  185. </el-form-item>
  186. <el-form-item label="续件运费" prop="continuePrice">
  187. <el-input v-model="form.continuePrice" placeholder="请输入续件运费" />
  188. </el-form-item>
  189. <el-form-item label="计费方式" prop="type">
  190. <el-select v-model="form.type" placeholder="请选择计费方式">
  191. <el-option label="请选择字典生成" value="" />
  192. </el-select>
  193. </el-form-item>
  194. <el-form-item label="分组唯一值" prop="productId">
  195. <el-input v-model="form.productId" placeholder="请输入分组唯一值" />
  196. </el-form-item>
  197. </el-form>
  198. <div slot="footer" class="dialog-footer">
  199. <el-button type="primary" @click="submitForm">确 定</el-button>
  200. <el-button @click="cancel">取 消</el-button>
  201. </div>
  202. </el-dialog>
  203. </div>
  204. </template>
  205. <script>
  206. import { listShippingTemplatesRegion, getShippingTemplatesRegion, delShippingTemplatesRegion, addShippingTemplatesRegion, updateShippingTemplatesRegion, exportShippingTemplatesRegion } from "@/api/store/shippingTemplatesRegion";
  207. export default {
  208. name: "ShippingTemplatesRegion",
  209. data() {
  210. return {
  211. // 遮罩层
  212. loading: true,
  213. // 选中数组
  214. ids: [],
  215. // 非单个禁用
  216. single: true,
  217. // 非多个禁用
  218. multiple: true,
  219. // 显示搜索条件
  220. showSearch: true,
  221. // 总条数
  222. total: 0,
  223. // 邮费区域表格数据
  224. shippingTemplatesRegionList: [],
  225. // 弹出层标题
  226. title: "",
  227. // 是否显示弹出层
  228. open: false,
  229. // 查询参数
  230. queryParams: {
  231. pageNum: 1,
  232. pageSize: 10,
  233. provinceId: null,
  234. tempId: null,
  235. cityId: null,
  236. first: null,
  237. firstPrice: null,
  238. continues: null,
  239. continuePrice: null,
  240. type: null,
  241. productId: null
  242. },
  243. // 表单参数
  244. form: {},
  245. // 表单校验
  246. rules: {
  247. provinceId: [
  248. { required: true, message: "省ID不能为空", trigger: "blur" }
  249. ],
  250. tempId: [
  251. { required: true, message: "模板ID不能为空", trigger: "blur" }
  252. ],
  253. cityId: [
  254. { required: true, message: "城市ID不能为空", trigger: "blur" }
  255. ],
  256. first: [
  257. { required: true, message: "首件不能为空", trigger: "blur" }
  258. ],
  259. firstPrice: [
  260. { required: true, message: "首件运费不能为空", trigger: "blur" }
  261. ],
  262. continues: [
  263. { required: true, message: "续件不能为空", trigger: "blur" }
  264. ],
  265. continuePrice: [
  266. { required: true, message: "续件运费不能为空", trigger: "blur" }
  267. ],
  268. type: [
  269. { required: true, message: "计费方式不能为空", trigger: "change" }
  270. ],
  271. productId: [
  272. { required: true, message: "分组唯一值不能为空", trigger: "blur" }
  273. ]
  274. }
  275. };
  276. },
  277. created() {
  278. this.getList();
  279. },
  280. methods: {
  281. /** 查询邮费区域列表 */
  282. getList() {
  283. this.loading = true;
  284. listShippingTemplatesRegion(this.queryParams).then(response => {
  285. this.shippingTemplatesRegionList = response.rows;
  286. this.total = response.total;
  287. this.loading = false;
  288. });
  289. },
  290. // 取消按钮
  291. cancel() {
  292. this.open = false;
  293. this.reset();
  294. },
  295. // 表单重置
  296. reset() {
  297. this.form = {
  298. id: null,
  299. provinceId: null,
  300. tempId: null,
  301. cityId: null,
  302. first: null,
  303. firstPrice: null,
  304. continues: null,
  305. continuePrice: null,
  306. type: null,
  307. productId: null
  308. };
  309. this.resetForm("form");
  310. },
  311. /** 搜索按钮操作 */
  312. handleQuery() {
  313. this.queryParams.pageNum = 1;
  314. this.getList();
  315. },
  316. /** 重置按钮操作 */
  317. resetQuery() {
  318. this.resetForm("queryForm");
  319. this.handleQuery();
  320. },
  321. // 多选框选中数据
  322. handleSelectionChange(selection) {
  323. this.ids = selection.map(item => item.id)
  324. this.single = selection.length!==1
  325. this.multiple = !selection.length
  326. },
  327. /** 新增按钮操作 */
  328. handleAdd() {
  329. this.reset();
  330. this.open = true;
  331. this.title = "添加邮费区域";
  332. },
  333. /** 修改按钮操作 */
  334. handleUpdate(row) {
  335. this.reset();
  336. const id = row.id || this.ids
  337. getShippingTemplatesRegion(id).then(response => {
  338. this.form = response.data;
  339. this.open = true;
  340. this.title = "修改邮费区域";
  341. });
  342. },
  343. /** 提交按钮 */
  344. submitForm() {
  345. this.$refs["form"].validate(valid => {
  346. if (valid) {
  347. if (this.form.id != null) {
  348. updateShippingTemplatesRegion(this.form).then(response => {
  349. if (response.code === 200) {
  350. this.msgSuccess("修改成功");
  351. this.open = false;
  352. this.getList();
  353. }
  354. });
  355. } else {
  356. addShippingTemplatesRegion(this.form).then(response => {
  357. if (response.code === 200) {
  358. this.msgSuccess("新增成功");
  359. this.open = false;
  360. this.getList();
  361. }
  362. });
  363. }
  364. }
  365. });
  366. },
  367. /** 删除按钮操作 */
  368. handleDelete(row) {
  369. const ids = row.id || this.ids;
  370. this.$confirm('是否确认删除邮费区域编号为"' + ids + '"的数据项?', "警告", {
  371. confirmButtonText: "确定",
  372. cancelButtonText: "取消",
  373. type: "warning"
  374. }).then(function() {
  375. return delShippingTemplatesRegion(ids);
  376. }).then(() => {
  377. this.getList();
  378. this.msgSuccess("删除成功");
  379. }).catch(function() {});
  380. },
  381. /** 导出按钮操作 */
  382. handleExport() {
  383. const queryParams = this.queryParams;
  384. this.$confirm('是否确认导出所有邮费区域数据项?', "警告", {
  385. confirmButtonText: "确定",
  386. cancelButtonText: "取消",
  387. type: "warning"
  388. }).then(function() {
  389. return exportShippingTemplatesRegion(queryParams);
  390. }).then(response => {
  391. this.download(response.msg);
  392. }).catch(function() {});
  393. }
  394. }
  395. };
  396. </script>