index.vue 14 KB

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