jiangping
2023-08-17 6365ab0a976afdd247742c9b3dca15deb3a7a7a1
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
<template>
  <GlobalAlertWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <div class="tips-style">调整有效期后,客户的有效期会发生改变,请谨慎操作</div>
    <el-form :model="form" ref="form" label-width="100px" label-suffix=":" :rules="rules" inline>
      <div class="short-line">
        <el-form-item label="客户简称" prop="remark">
          <el-input v-model="form.remark" disabled v-trim/>
        </el-form-item>
      </div>
      <div class="item-line">
        <el-form-item label="客户类型"  prop="oepnType">
          <el-radio-group v-model="form.oepnType" @change="typeChange">
            <el-radio :label="1">正式账号</el-radio>
            <el-radio :label="0">试用账号</el-radio>
          </el-radio-group>
        </el-form-item>
      </div>
      <div class="item-line">
        <el-form-item label="有效期" prop="oepnValidDate">
          <el-date-picker
            v-model="form.oepnValidDate"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd hh:mm:ss"
            placeholder="选择日期">
          </el-date-picker>
          有效期包含选择日期
        </el-form-item>
      </div>
    </el-form>
    <!-- <div slot="footer"></div> -->
  </GlobalAlertWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
import UploadImage from '../common/UploadImage.vue'
import { updateValidDate as update } from '@/api/business/clientManger'
// import { create } from '@/api/business/companyChange'
export default {
  name: 'OperaClientValidDateWindow',
  extends: BaseOpera,
  components: { GlobalAlertWindow, UploadImage },
  data () {
    
    return {
      isUploading: false,
      // 表单数据
      form: {
        id: null,
       
        oepnType: '1',
        remark: '',
        oepnValidDate: ''
      },
      types:[],
      // 验证规则
      rules: {
        
      }
    }
  },
  created () {
    this.config({
      api: '/business/clientManger',
      'field.id': 'id'
    })
  },
  methods: {
    open (title, target) {
      this.title = title
      this.visible = true
      // 编辑
      this.$nextTick(() => {
        this.$refs.form.clearValidate()
        this.$refs.form.resetFields()
        for (const key in this.form) {
          this.form[key] = target[key]
        }
      })
    },
    typeChange() {
      let tempDate = new Date();
      tempDate.setDate(tempDate.getDate() + (this.form.oepnType ? 30 : 15))
      this.form.oepnValidDate = `${tempDate.getFullYear()}-${tempDate.getMonth()+1}-${tempDate.getDate()} 00:00:00`
    },
    confirm() {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        this.isWorking = true
        update({
          ...this.form,
          companyId: this.form.id,
          validDate: this.form.oepnValidDate
        })
          .then(() => {
            this.visible = false
            this.$refs.form.resetFields()
            this.$message.success('修改有效期成功')
            this.$emit('success')
          })
          .catch(e => {
            this.$message.error(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    }
  },
}
</script>
 
<style lang="scss" scoped>
.tips-style {
  background-color: #f7f7f7;
  height: 30px;
  line-height: 30px;
  a {
    text-decoration:none
  }
  padding-left: 10px;
  margin-bottom: 20px;
}
.item-line {
  ::v-deep .el-form-item__content {
    width: 480px;
  }
}
.short-line {
  ::v-deep .el-form-item__content {
    width: 286px;
  }
}
.pic-line {
  ::v-deep .el-form-item__content {
    width: 500px;
  }
}
.address {
  display: flex;
  .line {
    width: 10px;
  }
}
.sub-title {
  font-size: 20px;
  font-weight: 600;
  margin-top: 10px;
  margin-bottom: 10px;
}
 
</style>