index.vue 13 KB

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