|
@@ -0,0 +1,234 @@
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog v-drag-dialog
|
|
|
+ :visible.sync="showDialog"
|
|
|
+ :title="title"
|
|
|
+ :modal-append-to-body="true"
|
|
|
+ append-to-body
|
|
|
+ style="text-align:left;"
|
|
|
+ width="600px"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ @close="closeDialog"
|
|
|
+ >
|
|
|
+ <div class="user-panel" v-loading="loading">
|
|
|
+ <el-form ref="form" :model="formModel" inline :rules="ruleValidate" :label-width="'150px'">
|
|
|
+ <el-table
|
|
|
+ :data="formModel.tableData"
|
|
|
+ v-loading="loading"
|
|
|
+ stripe
|
|
|
+ >
|
|
|
+ <el-table-column prop="startTime" label="时段" width="250">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-select v-model="scope.row.timeRange" size="mini">
|
|
|
+ <el-option
|
|
|
+ v-for="(price,index) in priceList"
|
|
|
+ :key="index"
|
|
|
+ :label="price.startTime + '至' + price.endTime"
|
|
|
+ :value="price.startTime + ',' + price.endTime"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="servicePrice" label="服务费(元)" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input-number :precision="2" :step="0.1" :min="0" v-model="scope.row.servicePrice" size="mini">
|
|
|
+ </el-input-number>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="150" fixed="right">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <i class="el-icon-delete my-font" @click="handleDelete(row)"></i>
|
|
|
+ <i class="el-icon-document-add my-font" @click="handleInsert(row)"></i>
|
|
|
+ <i class="el-icon-document-copy my-font" @click="handleCopy(row)"></i>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form>
|
|
|
+ <div class="el-table__empty-block">
|
|
|
+ <el-button icon="el-icon-circle-plus-outline" @click="handleAdd()">新增</el-button>
|
|
|
+ <el-button icon="el-icon-circle-plus-outline" @click="handleAddAll()">新增所有时段</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="closeDialog">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <script>
|
|
|
+ import vipTimeSharingPriceApi from "@/api/base/vipTimeSharingPrice";
|
|
|
+
|
|
|
+ export default {
|
|
|
+ props: ["title", "stationId","platformId"],
|
|
|
+ computed: {
|
|
|
+ ruleValidate (){
|
|
|
+ var rules = null;
|
|
|
+ rules = {
|
|
|
+ startTime: [
|
|
|
+ { required: true, message: "开始时段不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ endTime: [
|
|
|
+ { required: true, message: "结束时段不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ servicePrice: [
|
|
|
+ { required: true, message: "服务费不能为空", trigger: "blur" }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ return rules;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ showDialog: true,
|
|
|
+ loading: false,
|
|
|
+ submitting: false,
|
|
|
+ priceList: [],
|
|
|
+ formModel: {
|
|
|
+ tableData:[]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ closeDialog() {
|
|
|
+ this.$emit("close", false);
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ if(self.platformId==null){
|
|
|
+ self.$message.warning("VIP平台编号为空!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$refs["form"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ self.formModel.tableData.forEach(row=>{
|
|
|
+ let timeRange = row.timeRange.split(',')
|
|
|
+
|
|
|
+ row.startTime = timeRange[0];
|
|
|
+ row.endTime = timeRange[1];
|
|
|
+ });
|
|
|
+
|
|
|
+ vipTimeSharingPriceApi
|
|
|
+ .batchSetPrice(self.stationId,self.platformId,self.formModel.tableData)
|
|
|
+ .then(function (response) {
|
|
|
+ self.loading = false;
|
|
|
+
|
|
|
+ var jsonData = response.data;
|
|
|
+
|
|
|
+ if (jsonData.result) {
|
|
|
+ self.$message({
|
|
|
+ message: "保存成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+
|
|
|
+ self.$emit("close", true);
|
|
|
+ } else {
|
|
|
+ self.$message({
|
|
|
+ message: jsonData.message + "",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+
|
|
|
+ //self.$emit("close", false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.formModel.tableData.push({
|
|
|
+ stationId:this.stationId,
|
|
|
+ timeRange: "",
|
|
|
+ startTime:"",
|
|
|
+ endTime: "",
|
|
|
+ servicePrice: 0
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleAddAll() {
|
|
|
+ this.priceList.forEach(price=>{
|
|
|
+ this.formModel.tableData.push({
|
|
|
+ stationId:this.stationId,
|
|
|
+ timeRange: price.startTime + "," + price.endTime,
|
|
|
+ startTime:price.startTime,
|
|
|
+ endTime: price.endTime,
|
|
|
+ servicePrice: 0
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleInsert(row) {
|
|
|
+ var tableData = this.formModel.tableData;
|
|
|
+ var index = tableData.indexOf(row);
|
|
|
+
|
|
|
+ if(index>=0){
|
|
|
+ tableData.splice(index+1,0,{
|
|
|
+ stationId:this.stationId,
|
|
|
+ timeRange: "",
|
|
|
+ startTime:"",
|
|
|
+ endTime: "",
|
|
|
+ servicePrice: 0
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ var tableData = this.formModel.tableData;
|
|
|
+ tableData.splice(tableData.indexOf(row), 1);
|
|
|
+ },
|
|
|
+ handleCopy(row) {
|
|
|
+ var tableData = this.formModel.tableData;
|
|
|
+ tableData.forEach(item=>{
|
|
|
+ item.servicePrice = row.servicePrice;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleChangeStartTime(row) {
|
|
|
+ this.priceList.forEach(price=>{
|
|
|
+ if(price.startTime==row.startTime){
|
|
|
+ row.endTime = price.endTime;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ vipTimeSharingPriceApi.queryPriceList(this.stationId)
|
|
|
+ .then((response) => {
|
|
|
+ var jsonData = response.data;
|
|
|
+
|
|
|
+ if (jsonData.result) {
|
|
|
+ this.priceList = jsonData.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ mounted: function () {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ (function () {
|
|
|
+ return vipTimeSharingPriceApi.edit(self.stationId,self.platformId);
|
|
|
+ })()
|
|
|
+ .then((response) => {
|
|
|
+ var jsonData = response.data;
|
|
|
+ self.loading = false;
|
|
|
+
|
|
|
+ if (jsonData.result) {
|
|
|
+ jsonData.data.forEach(item=>{
|
|
|
+ item.timeRange = item.startTime + "," + item.endTime
|
|
|
+ })
|
|
|
+
|
|
|
+ self.formModel.tableData = jsonData.data;
|
|
|
+ } else {
|
|
|
+ self.$message.error(jsonData.message + "");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ self.$message.error(error + "");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+ <style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
+ .my-font {
|
|
|
+ font-size: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ </style>
|