|
|
@@ -19,13 +19,13 @@
|
|
|
<span>
|
|
|
<i>*</i>型号:
|
|
|
</span>
|
|
|
- <input type="text" class="form-control" :class="{'error': !validObj.code}" v-model="applyObj.code" maxlength="30" @blur="checkCode" />
|
|
|
+ <input type="text" class="form-control" :class="{'error': !validObj.code}" v-model="applyObj.code" maxlength="30" @blur="checkCode" @input="onCodeChange" />
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<span>
|
|
|
<i>*</i>品牌:
|
|
|
</span>
|
|
|
- <input type="text" class="form-control" :class="{'error': !validObj.brand}" maxlength="20" v-model="applyObj.brand" @blur="checkBrand" />
|
|
|
+ <input type="text" class="form-control" :class="{'error': !validObj.brand}" maxlength="20" v-model="applyObj.brand" @blur="checkBrand" @input="onBrandChange" />
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<span>
|
|
|
@@ -41,19 +41,19 @@
|
|
|
<span>
|
|
|
封装:
|
|
|
</span>
|
|
|
- <input type="text" class="form-control" maxlength="20" v-model="applyObj.encapsulation" />
|
|
|
+ <input type="text" class="form-control" maxlength="20" v-model="applyObj.encapsulation" @input="onEncapsulationChange" />
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<span>
|
|
|
生产日期:
|
|
|
</span>
|
|
|
- <input type="text" class="form-control" v-model="applyObj.produceDate" />
|
|
|
+ <input type="text" class="form-control" v-model="applyObj.produceDate" @input="onProduceDateChange" />
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<span>
|
|
|
采购数量:
|
|
|
</span>
|
|
|
- <input type="number" class="form-control" :class="{'error': !validObj.amount}" v-model="applyObj.amount" @blur="checkAmount" @input="onAmountInput" />
|
|
|
+ <input type="number" class="form-control" :class="{'error': !validObj.amount}" v-model="applyObj.amount" @blur="checkAmount" />
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<span>
|
|
|
@@ -65,6 +65,7 @@
|
|
|
type="date"
|
|
|
:picker-options="pickerOptions"
|
|
|
:class="{'error': !validObj.deadline}"
|
|
|
+ @change="checkDeadline"
|
|
|
size="mini">
|
|
|
</el-date-picker>
|
|
|
</div>
|
|
|
@@ -119,6 +120,17 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ let getRealLen = function (str) {
|
|
|
+ let len = 0
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
|
|
+ len += 2
|
|
|
+ } else {
|
|
|
+ len++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return len
|
|
|
+ }
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
@@ -229,15 +241,36 @@
|
|
|
return this.validObj.deadline
|
|
|
},
|
|
|
onUnitPriceInput: function () {
|
|
|
- if (this.applyObj.unitPrice < 0) {
|
|
|
- this.applyObj.unitPrice = 0
|
|
|
- } else if (this.applyObj.unitPrice.toString().indexOf('.') !== -1 && this.applyObj.unitPrice.toString().split('.')[1].length > 6) {
|
|
|
- this.applyObj.unitPrice = Number(this.applyObj.unitPrice).toFixed(6)
|
|
|
+ let price = this.applyObj.unitPrice
|
|
|
+ if (price >= 9999) {
|
|
|
+ this.applyObj.unitPrice = price.substring(0, 4)
|
|
|
+ } else if (price.indexOf('.') > -1) {
|
|
|
+ let arr = price.split('.')
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ this.applyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ this.applyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onProduceDateChange: function () {
|
|
|
+ if (this.applyObj.produceDate && getRealLen(this.applyObj.produceDate) > 12) {
|
|
|
+ this.applyObj.produceDate = this.applyObj.produceDate.substring(0, this.applyObj.produceDate.length - 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onEncapsulationChange: function () {
|
|
|
+ if (this.applyObj.encapsulation && getRealLen(this.applyObj.encapsulation) > 20) {
|
|
|
+ this.applyObj.encapsulation = this.applyObj.encapsulation.substring(0, this.applyObj.encapsulation.length - 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCodeChange: function () {
|
|
|
+ if (this.applyObj.code && getRealLen(this.applyObj.code) > 30) {
|
|
|
+ this.applyObj.code = this.applyObj.code.substring(0, this.applyObj.code.length - 1)
|
|
|
}
|
|
|
},
|
|
|
- onAmountInput: function () {
|
|
|
- if (this.applyObj.amount < 0) {
|
|
|
- this.applyObj.amount = 0
|
|
|
+ onBrandChange: function () {
|
|
|
+ if (this.applyObj.brand && getRealLen(this.applyObj.brand) > 20) {
|
|
|
+ this.applyObj.brand = this.applyObj.brand.substring(0, this.applyObj.brand.length - 1)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -276,6 +309,7 @@
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
+ text-align: left;
|
|
|
}
|
|
|
i {
|
|
|
display: inline-block;
|