index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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="oilName">
  5. <el-input
  6. v-model="queryParams.oilName"
  7. placeholder="请输入油品名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="油品价格" prop="oilPrice">
  14. <el-input
  15. v-model="queryParams.oilPrice"
  16. placeholder="请输入油品价格"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="油站名称" prop="stationNanme">
  23. <el-input
  24. v-model="queryParams.stationNanme"
  25. placeholder="请输入油站名称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="操作时间" prop="date">
  32. <el-date-picker clearable size="small" style="width: 200px"
  33. v-model="queryParams.date"
  34. type="date"
  35. value-format="yyyy-MM-dd"
  36. placeholder="选择操作时间">
  37. </el-date-picker>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="primary"
  48. icon="el-icon-plus"
  49. size="mini"
  50. @click="handleAdd"
  51. v-hasPermi="['station:price:add']"
  52. >新增</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="success"
  57. icon="el-icon-edit"
  58. size="mini"
  59. :disabled="single"
  60. @click="handleUpdate"
  61. v-hasPermi="['station:price:edit']"
  62. >修改</el-button>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-button
  66. type="danger"
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['station:price:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="warning"
  77. icon="el-icon-download"
  78. size="mini"
  79. @click="handleExport"
  80. v-hasPermi="['station:price:export']"
  81. >导出</el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table v-loading="loading" :data="priceList" @selection-change="handleSelectionChange">
  86. <el-table-column type="selection" width="55" align="center" />
  87. <el-table-column label="油品价格id" v-if="getHiddenColumns" align="center" prop="oilPriceId" />
  88. <el-table-column label="油品名称" align="center" prop="oilName" />
  89. <el-table-column label="油品价格" align="center" prop="oilPrice" />
  90. <el-table-column label="油站id" v-if="getHiddenColumns" align="center" prop="stationId" />
  91. <el-table-column label="油站名称" align="center" prop="stationNanme" />
  92. <el-table-column label="操作时间" align="center" prop="date" width="180">
  93. <template slot-scope="scope">
  94. <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  98. <template slot-scope="scope">
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-edit"
  103. @click="handleUpdate(scope.row)"
  104. v-hasPermi="['station:price:edit']"
  105. >修改</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. @click="handleDelete(scope.row)"
  111. v-hasPermi="['station:price:remove']"
  112. >删除</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改油品价格对话框 -->
  124. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  125. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  126. <el-form-item label="油品名称" prop="oilName">
  127. <el-input v-model="form.oilName" placeholder="请输入油品名称" />
  128. </el-form-item>
  129. <el-form-item label="油品价格" prop="oilPrice">
  130. <el-input v-model="form.oilPrice" placeholder="请输入油品价格" />
  131. </el-form-item>
  132. <el-form-item label="油站id" prop="stationId">
  133. <el-input v-model="form.stationId" placeholder="请输入油站id" />
  134. </el-form-item>
  135. <el-form-item label="油站名称" prop="stationNanme">
  136. <el-input v-model="form.stationNanme" placeholder="请输入油站名称" />
  137. </el-form-item>
  138. <el-form-item label="操作时间" prop="date">
  139. <el-date-picker clearable size="small" style="width: 200px"
  140. v-model="form.date"
  141. type="date"
  142. value-format="yyyy-MM-dd"
  143. placeholder="选择操作时间">
  144. </el-date-picker>
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button type="primary" @click="submitForm">确 定</el-button>
  149. <el-button @click="cancel">取 消</el-button>
  150. </div>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import { listPrice, getPrice, delPrice, addPrice, updatePrice, exportPrice } from "@/api/station/price";
  156. export default {
  157. name: "Price",
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 选中数组
  163. ids: [],
  164. // 非单个禁用
  165. single: true,
  166. // 非多个禁用
  167. multiple: true,
  168. // 显示搜索条件
  169. showSearch: true,
  170. // 总条数
  171. total: 0,
  172. // 油品价格表格数据
  173. priceList: [],
  174. // 弹出层标题
  175. title: "",
  176. // 是否显示弹出层
  177. open: false,
  178. // 查询参数
  179. queryParams: {
  180. pageNum: 1,
  181. pageSize: 10,
  182. oilName: null,
  183. oilPrice: null,
  184. stationId: null,
  185. stationNanme: null,
  186. date: null
  187. },
  188. // 表单参数
  189. form: {},
  190. // 表单校验
  191. rules: {
  192. }
  193. };
  194. },
  195. created() {
  196. this.getList();
  197. },
  198. methods: {
  199. /** 查询油品价格列表 */
  200. getList() {
  201. this.loading = true;
  202. listPrice(this.queryParams).then(response => {
  203. this.priceList = 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. oilPriceId: null,
  217. oilName: null,
  218. oilPrice: null,
  219. stationId: null,
  220. stationNanme: null,
  221. date: null
  222. };
  223. this.resetForm("form");
  224. },
  225. /** 搜索按钮操作 */
  226. handleQuery() {
  227. this.queryParams.pageNum = 1;
  228. this.getList();
  229. },
  230. /** 重置按钮操作 */
  231. resetQuery() {
  232. this.resetForm("queryForm");
  233. this.handleQuery();
  234. },
  235. // 多选框选中数据
  236. handleSelectionChange(selection) {
  237. this.ids = selection.map(item => item.oilPriceId)
  238. this.single = selection.length!==1
  239. this.multiple = !selection.length
  240. },
  241. /** 新增按钮操作 */
  242. handleAdd() {
  243. this.reset();
  244. this.open = true;
  245. this.title = "添加油品价格";
  246. },
  247. /** 修改按钮操作 */
  248. handleUpdate(row) {
  249. this.reset();
  250. const oilPriceId = row.oilPriceId || this.ids
  251. getPrice(oilPriceId).then(response => {
  252. this.form = response.data;
  253. this.open = true;
  254. this.title = "修改油品价格";
  255. });
  256. },
  257. /** 提交按钮 */
  258. submitForm() {
  259. this.$refs["form"].validate(valid => {
  260. if (valid) {
  261. if (this.form.oilPriceId != null) {
  262. updatePrice(this.form).then(response => {
  263. this.msgSuccess("修改成功");
  264. this.open = false;
  265. this.getList();
  266. });
  267. } else {
  268. addPrice(this.form).then(response => {
  269. this.msgSuccess("新增成功");
  270. this.open = false;
  271. this.getList();
  272. });
  273. }
  274. }
  275. });
  276. },
  277. /** 删除按钮操作 */
  278. handleDelete(row) {
  279. const oilPriceIds = row.oilPriceId || this.ids;
  280. this.$confirm('是否确认删除油品价格编号为"' + oilPriceIds + '"的数据项?', "警告", {
  281. confirmButtonText: "确定",
  282. cancelButtonText: "取消",
  283. type: "warning"
  284. }).then(function() {
  285. return delPrice(oilPriceIds);
  286. }).then(() => {
  287. this.getList();
  288. this.msgSuccess("删除成功");
  289. })
  290. },
  291. /** 导出按钮操作 */
  292. handleExport() {
  293. const queryParams = this.queryParams;
  294. this.$confirm('是否确认导出所有油品价格数据项?', "警告", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning"
  298. }).then(function() {
  299. return exportPrice(queryParams);
  300. }).then(response => {
  301. this.download(response.msg);
  302. })
  303. }
  304. }
  305. };
  306. </script>