feeDialog.vue 9.71 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
<template>
	<el-dialog v-dialogDrag title="费用调整" v-if="visiable" :visible.sync="visiable" center destroy-on-close :before-close="beforeClose" width="70%">
		<el-form ref="dialogForm" :model="formData" :rules="rules" label-width="120px" class="dialog-wrap">
			<el-row class="card">
				<div class="card-content">
					<c-col :span="12">
						<c-col :span="24">
							<el-form-item label="费用代码">
								<c-input v-model="formData.feecod" disabled />
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="计费开始日期" prop="beginDate">
								<c-date-picker v-model="formData.beginDate" type="date" @change="adjustFec('beginDate')" placeholder="请选择收费开始日期" disabled>
								</c-date-picker>
							</el-form-item>
						</c-col>
            <c-col :span="24">
							<el-form-item label="币种">
								<c-input v-model="formData.feecur" disabled />
							</el-form-item>
						</c-col>
            <c-col :span="24">
							<el-form-item label="费率类型">
								<c-select v-model="formData.calrul" dbCode="CALRUL" uil="CN" disabled placeholder="请选择费率类型">
								</c-select>
							</el-form-item>
						</c-col>
            <c-col :span="24">
							<el-form-item label="百分费率" v-if="formData.calrul==='%'" prop="ratcal">
								<c-col :span="22">
									<c-input-currency :precision="6" v-model="formData.ratcal" @change="adjustFec('ratcal')"></c-input-currency>
								</c-col>
								<c-col :span="1" style="float: right; text-align: right">
									<span v-if="formData.calrul==='%'">%</span>
								</c-col>
							</el-form-item>
							<el-form-item label="千分费率" v-if="formData.calrul==='1'" prop="ratcal">
								<c-col :span="22">
									<c-input-currency :precision="6" v-model="formData.ratcal" @change="adjustFec('ratcal')"></c-input-currency>
								</c-col>
								<c-col :span="2" style="float: right; text-align: right">
									<span v-if="formData.calrul==='1'"></span>
								</c-col>
							</el-form-item>
							<el-form-item label="固定金额" v-if="formData.calrul==='0'" prop="untamt">
								<c-col :span="10">
									<c-input v-model="formData.ratcur" disabled />
								</c-col>
								<c-col :span="14">
									<c-input-currency v-model="formData.untamt" :currency="formData.ratcur" @change="adjustFec('untamt')" />
								</c-col>
							</el-form-item>
              <el-form-item label="万分费率" v-if="formData.calrul==='B'" prop="ratcal">
								<c-col :span="22">
									<c-input-currency :precision="6" v-model="formData.ratcal" @change="adjustFec('ratcal')"></c-input-currency>
								</c-col>
								<c-col :span="2" style="float: right; text-align: right">
									<span v-if="formData.calrul==='B'"></span>
								</c-col>
							</el-form-item>
						</c-col>
					</c-col>

					<!-- ==================右边================ -->
					<c-col :span="12" style="padding-left: 20px">
						<c-col :span="24">
							<el-form-item label="收取份数" prop="unt">
								<c-input-number :min=0 v-model="formData.unt" @change="adjustFec('unt')"/>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="计费结束日期" prop="endDate">
								<c-date-picker v-model="formData.endDate" type="date" disabled @change="adjustFec('endDate')" placeholder="请选择收费结束日期">
								</c-date-picker>
							</el-form-item>
						</c-col>
            <c-col :span="24">
							<el-form-item label="未收取金额">
								<c-input-currency v-model="formData.feeamt" :currency="formData.feecur" @change="adjustFec('feeamt')"/>
							</el-form-item>
						</c-col>
            <c-col :span="24">
							<el-form-item label="计费周期">
								<c-select v-model="formData.pertyp"
                :filterKey="['d','q','CALMON','y']"
                dbCode="PERTYP" uil="CN" @change="adjustFec('pertyp')" placeholder="请选择周期类型">
								</c-select>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="计算基准">
								<c-select v-model="formData.calcbs" dbCode="calcbs"  uil="CN" disabled placeholder="请选择计算基准">
								</c-select>
							</el-form-item>
						</c-col>
					</c-col>
				</div>
			</el-row>
			<el-row class="card" v-if="formData.calrul !== '0'">
				<div class="card-content">
					<c-col :span="24">
						<c-col :span="12">
							<el-form-item label="最小收费币种">
								<c-input v-model="formData.mincur" disabled/>
							</el-form-item>
						</c-col>
						<c-col :span="12" style="padding-left: 20px">
							<el-form-item label="最小收费金额">
								<c-input-currency v-model="formData.minamt" :currency="formData.mincur" @change="adjustFec('minamt')" />
							</el-form-item>
						</c-col>
					</c-col>
					<c-col :span="24">
						<c-col :span="12">
							<el-form-item label="最大收费币种">
								<c-input v-model="formData.maxcur" disabled/>
							</el-form-item>
						</c-col>
						<c-col :span="12" style="padding-left: 20px">
							<el-form-item label="最大收费金额">
								<c-input-currency v-model="formData.maxamt" :currency="formData.maxcur" @change="adjustFec('maxamt')" />
							</el-form-item>
						</c-col>
					</c-col>
				</div>
			</el-row>
			<el-row>
				<c-col :span="24">
					<el-form-item label="费用计算明细">
						<el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="formData.inftxt" disabled>
						</el-input>
					</el-form-item>
				</c-col>
			</el-row>
			<!-- ==================左边================ -->
		</el-form>
		<div slot="footer" class="dialog-footer">
			<c-button type="primary" @click="saveDialog" style="margin-right: 20px;">确 定</c-button>
			<c-button @click="resetDialog">重 置</c-button>
		</div>
	</el-dialog>
</template>

<script>
import commonDepend from "~/mixin/commonDepend.js";
import Api from "~/service/Api"
import commonFunctions from '~/mixin/commonFunctions.js';
export default {
  inject: ["root"],
  mixins: [commonDepend, commonFunctions],
  props: {
    dialog: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      formData: {},
      visiable: false,
      rules: {
        "ratcal": [{ required: true, message: "必填" }],
        "untamt": [{ required: true, message: "必填" }],
        "days": [{ required: true, message: "必填" },
        { validator: this.validateDays, trigger: ["blur", "change"] }],
        "endDate": [{ required: true, message: "必填" },
        { validator: this.validateDate, trigger: ["blur", "change"] }]
      }
    };
  },
  methods: {
    //初始化
    init() {
      for (let key in this.dialog) {
        this.$set(this.formData, key, this.dialog[key]);
      }
    },
    adjustFec(prop) {
      this.$refs.dialogForm.validate(async valid => {
        if (!valid) {
          console.log("详细填写不合法");
          return;
        }
        if (prop === 'feeamt') {
          this.formData.inftxt = '';
          this.formData.modflg = 'a';
          return;
        } else if (prop === 'unt') {
          this.formData.modflg = 'u';
        }
        const loading = this.loading()
        let rtnmsg = await Api.post("/business/comsel/adjustFec", this.formData);
        if (rtnmsg.respCode === SUCCESS) {
					this.formData.feeamt = rtnmsg.data.feeamt;
					this.formData.inftxt = rtnmsg.data.inftxt;
					this.formData.unt = rtnmsg.data.unt;
					this.formData.endDate = rtnmsg.data.endDate;
					this.formData.ratcal = rtnmsg.data.ratcal;
					this.formData.modflg = '';
        }
        loading.close();
      });
    },
    //确定
    saveDialog() {
      this.$refs.dialogForm.validate(valid => {
        if (!valid) {
          console.log("详细填写不合法");
          return;
        }
        this.visiable = false;
        this.$emit("saveDialog", this.formData);
      });
    },
    //取消
    beforeClose(done) {
      this.visiable = false;
      done();
    },
    //重置
    async resetDialog() {
        const loading = this.loading()
        let rtnmsg = await Api.post("/business/comsel/resetFec", this.formData);
        if (rtnmsg.respCode === SUCCESS) {
          this.formData.unt = rtnmsg.data.unt;
          this.formData.endDate = rtnmsg.data.endDate;
          this.formData.feeamt = rtnmsg.data.feeamt;
          this.formData.ratcal = rtnmsg.data.ratcal;
          this.formData.untamt = rtnmsg.data.untamt;
          this.formData.minamt = rtnmsg.data.minamt;
          this.formData.maxamt = rtnmsg.data.maxamt;
          this.formData.inftxt = rtnmsg.data.inftxt;
          this.formData.pertyp = rtnmsg.data.pertyp;
        }
        loading.close();
    },
    validateDate(rule, value, cb) {
      if (this.formData.beginDate && this.formData.endDate) {
        if (this.formData.beginDate > this.formData.endDate) {
          cb(new Error("收费开始日期不得大于收费结束日期"));
        }
      }
      cb();
    },
    validateDays(rule, value, cb) {
      if (this.formData.days < 1) {
          cb(new Error("计费天数不得小于1"));
      }
      cb();
    }
  }
};
</script>
<style scoped lang="less">
.dialog-wrap {
  height: 400px;
  overflow: auto;
}
// ::v-deep .el-dialog__header {
//   height: 36px;
//   .el-dialog__headerbtn {
//     top: 10px;
//   }
// }
::v-deep .el-dialog__body {
  padding: 10px 15px 10px;
  height: calc(100% - 110px);
  .el-form {
    height: 100%;
  }
}
::v-deep .el-dialog__footer {
  padding: 10px 10px 0;
}
.dialog-footer {
  padding: 0 !important;
}
.card {
  width: 100%;
}
.card-title {
  width: 100%;
  padding: 8px 0;
  font-size: 16px;
  color: #000;
}
.card-content {
  width: 100%;
}
::v-deep .el-range-separator {
  width: 8%;
  height: 32px;
  line-height: 32px !important;
}
::v-deep .el-date-editorr {
  height: 32px;
  line-height: 32px;
}
</style>