123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <div>
- <el-dialog
- :title="title"
- :close-on-click-modal="false"
- :visible.sync="visible">
- <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method==='view'"
- label-width="120px">
- <el-row :gutter="15">
- <el-col :span="12">
- <el-form-item label="年份" prop="yearOfEvaluation"
- :rules="[
- ]">
- <el-input readonly v-model="inputForm.yearOfEvaluation" placeholder="请填写年份" ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="名称" prop="unitName"
- :rules="[
- ]">
- <el-input readonly v-model="inputForm.unitName" placeholder="请填写名称" ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="扣分大类" prop="classId"
- :rules="[
- {required: true, message:'扣分大类不能为空', trigger:'blur'}
- ]">
- <el-select v-model="inputForm.classId" placeholder="请选择" @change="selectGoodsByGroupId($event)" style="width: 100%;">
- <el-option
- v-for="item in bigClass"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="扣分小类" prop="subClassId"
- :rules="[
- {required: true, message:'扣分小类不能为空', trigger:'blur'}
- ]">
- <el-select v-model="inputForm.subClassId" placeholder="请选择" @change="selectVeto($event)" style="width: 100%;">
- <el-option
- v-for="item in subClass"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item v-if="inputForm.veto != 1" label="扣分" prop="deductPoints"
- :rules="[
- {required: true, message:'扣分分数不为空', trigger:'blur'},
- {validator: isNumberZero, trigger:'blur'}
- ]">
- <el-input type="number" v-model="inputForm.deductPoints" placeholder="请填写扣分" ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="扣分详情" prop="deductionDetails"
- :rules="[
- {required: true, message:'扣分详情不为空', trigger:'blur'},
- ]">
- <el-input type="textarea" resize="none" :autosize="{ minRows: 4, maxRows: 4 }" v-model="inputForm.deductionDetails" placeholder="请填写扣分详情" ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="日期" prop="deductionDate"
- :rules="[
- {required: true, message:'扣分日期不为空', trigger:'blur'},
- ]">
- <el-date-picker
- style="width: 100%;"
- readonly
- v-model="inputForm.deductionDate"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="选择扣分日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item v-if="veto == '1'" label="是否否决" prop="veto"
- :rules="[
- {required: true, message:'是否否决不能为空', trigger:'blur'},
- ]">
- <el-select v-model="inputForm.veto" placeholder="请选择" style="width: 100%;">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="visible = false">关闭</el-button>
- <el-button type="primary" v-if="method != 'view'" @click="doSubmit()" v-noMoreClick>确定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- data () {
- return {
- title: '',
- method: '',
- visible: false,
- loading: false,
- isNumberZero: (rule, value, callback) => {
- const reg = /^[+]?[1-9]+$/
- if (!reg.test(value)) {
- return callback(new Error('情输入正确的扣分分数'))
- }
- this.$http.get(`/database/datalink/dataSource/checkEnName?oldEnName=${this.inputForm.oldEnName}&enName=${value}`).then(({data}) => {
- if (!data.success) {
- return callback(new Error('连接英文名已存在!'))
- } else {
- return callback()
- }
- })
- },
- inputForm: {
- id: '',
- unitId: '',
- classId: '',
- subClassId: '',
- yearOfEvaluation: '',
- unitName: '',
- bigName: '',
- serialNumber: '',
- smallName: '',
- deductPoints: '',
- deductionDetails: '',
- deductionDate: '',
- veto: ''
- },
- bigClass: [],
- subClass: [],
- veto: '0',
- options: [ {
- value: '0',
- label: '否'
- }, {
- value: '1',
- label: '是'
- }]
- }
- },
- components: {
- },
- methods: {
- init (method, id) {
- this.method = method
- this.inputForm.id = id
- if (method === 'add') {
- this.title = `新建扣分详细`
- } else if (method === 'edit') {
- this.title = '修改'
- } else if (method === 'view') {
- this.title = '查看扣分详细'
- }
- this.visible = true
- this.loading = false
- this.$nextTick(() => {
- this.$refs.inputForm.resetFields()
- if (method === 'edit' || method === 'view') { // 修改或者查看
- this.loading = true
- this.$http({
- url: `/deductionShowDetails/deductionShowDetails/queryById?id=${this.inputForm.id}`,
- method: 'get'
- }).then(({data}) => {
- console.log(data)
- this.inputForm = this.recover(this.inputForm, data.deductionShowDetails)
- this.veto = data.deductionShowDetails.veto
- this.$http({
- url: `/deductiondetails/deductionDetails/getBigClass?id=0`,
- method: 'get'
- }).then(({data}) => {
- this.bigClass = data.bigClass
- this.loading = false
- this.$http({
- url: `/deductiondetails/deductionDetails/getSubClass?id=${this.inputForm.classId}`,
- method: 'get'
- }).then(({data}) => {
- this.subClass = data.subClass
- this.loading = false
- })
- })
- this.loading = false
- })
- }
- })
- },
- // 表单提交
- doSubmit () {
- this.$refs['inputForm'].validate((valid) => {
- if (valid) {
- this.loading = true
- this.$http({
- url: `/deductionShowDetails/deductionShowDetails/update`,
- method: 'post',
- data: this.inputForm
- }).then(({data}) => {
- if (data && data.success) {
- this.visible = false
- this.$message.success(data.msg)
- this.$emit('refreshDataList')
- }
- this.loading = false
- })
- }
- })
- },
- selectGoodsByGroupId (val) {
- this.$http({
- url: `/deductiondetails/deductionDetails/getSubClass?id=${this.inputForm.classId}`,
- method: 'get'
- }).then(({data}) => {
- console.log(data)
- this.subClass = data.subClass
- this.inputForm.subClassId = ''
- this.loading = false
- })
- },
- selectVeto (val) {
- console.log(val)
- this.$http({
- url: `/deductiondetails/deductionDetails/getVeto?id=${this.inputForm.subClassId}`,
- method: 'get'
- }).then(({data}) => {
- console.log(data)
- this.veto = data.veto
- this.inputForm.veto = '0'
- this.loading = false
- })
- }
- }
- }
- </script>
|