|
|
@@ -28,16 +28,29 @@
|
|
|
<label :for="index"></label>
|
|
|
</label>
|
|
|
</td>
|
|
|
- <td>{{item.code}}</td>
|
|
|
- <td>{{item.brand}}</td>
|
|
|
+ <td>
|
|
|
+ <span v-if="item.code">{{item.code}}</span>
|
|
|
+ <span class="red-text" v-if="!item.code">请完善信息</span>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <span v-if="item.brand">{{item.brand}}</span>
|
|
|
+ <span class="red-text" v-if="!item.brand">请完善信息</span>
|
|
|
+ </td>
|
|
|
<td>{{item.amount || '-'}}</td>
|
|
|
- <td class="blue-text">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</td>
|
|
|
+ <td class="blue-text">
|
|
|
+ <span v-if="item.unitPrice">{{(item.currency === 'RMB' ? '¥' : '$') + item.unitPrice}}</span>
|
|
|
+ <span v-if="!item.unitPrice">-</span>
|
|
|
+ </td>
|
|
|
<td>{{item.encapsulation || '-'}}</td>
|
|
|
<td>{{item.produceDate}}</td>
|
|
|
- <td>{{item.deadline | date}}</td>
|
|
|
+ <td>
|
|
|
+ <span v-if="item.deadline">{{item.deadline | date}}</span>
|
|
|
+ <span class="red-text" v-if="!item.deadline">请完善信息</span>
|
|
|
+ <div class="red-text" v-if="!isValidTime(item.deadline)">默认≤90天</div>
|
|
|
+ </td>
|
|
|
<td class="operate">
|
|
|
<a class="delete-btn" @click="modifyItem(index)">编辑</a>
|
|
|
- <a class="delete-btn" @click="deleteItem(index)">删除</a>
|
|
|
+ <a class="modify-btn" @click="deleteItem(index)">删除</a>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<tr class="modify-row" v-if="item.active">
|
|
|
@@ -48,26 +61,32 @@
|
|
|
</label>
|
|
|
</td>
|
|
|
<td>
|
|
|
- <input type="text" class="form-control" v-model="modifyObj.code">
|
|
|
+ <input type="text" class="form-control" v-model="modifyObj.code" :class="{'error': !validObj.code}" maxlength="30" @blur="checkCode" @input="onCodeChange" >
|
|
|
+ <!-- <ul>
|
|
|
+ <li v-for="sCode in similarCode">{{sCode.code}}</li>
|
|
|
+ </ul>-->
|
|
|
</td>
|
|
|
<td>
|
|
|
- <input type="text" class="form-control" v-model="modifyObj.brand">
|
|
|
+ <input type="text" class="form-control" v-model="modifyObj.brand" :class="{'error': !validObj.brand}" maxlength="20" @blur="checkBrand" @input="onBrandChange">
|
|
|
+ <!--<ul>
|
|
|
+ <li v-for="sBrand in similarBrand">{{sBrand.nameEn}}</li>
|
|
|
+ </ul>-->
|
|
|
</td>
|
|
|
<td>
|
|
|
- <input type="text" class="form-control" v-model="modifyObj.amount">
|
|
|
+ <input type="text" class="form-control" v-model="modifyObj.amount" :class="{'error': !validObj.amount}" @blur="checkAmount">
|
|
|
</td>
|
|
|
<td>
|
|
|
<select class="form-control" v-model="modifyObj.currency">
|
|
|
<option value="RMB">¥</option>
|
|
|
<option value="USD">$</option>
|
|
|
</select>
|
|
|
- <input class="form-control" type="text" v-model="modifyObj.unitPrice">
|
|
|
+ <input class="form-control" type="number" v-model="modifyObj.unitPrice" :class="{'error': !validObj.unitPrice}" @blur="checkUnitPrice" @input="onUnitPriceInput">
|
|
|
</td>
|
|
|
<td>
|
|
|
- <input type="text" class="form-control" v-model="modifyObj.encapsulation">
|
|
|
+ <input type="text" class="form-control" v-model="modifyObj.encapsulation" maxlength="20" @input="onEncapsulationChange">
|
|
|
</td>
|
|
|
<td>
|
|
|
- <input type="text" class="form-control" v-model="modifyObj.produceDate">
|
|
|
+ <input type="text" class="form-control" v-model="modifyObj.produceDate" @input="onProduceDateChange">
|
|
|
</td>
|
|
|
<td>
|
|
|
<el-date-picker
|
|
|
@@ -75,7 +94,6 @@
|
|
|
type="date"
|
|
|
:picker-options="pickerOptions"
|
|
|
:editable="false"
|
|
|
- :clearable="true"
|
|
|
size="mini">
|
|
|
</el-date-picker>
|
|
|
<!--<input type="text" class="form-control" v-model="modifyObj.deadline">-->
|
|
|
@@ -90,7 +108,7 @@
|
|
|
<page :total="bomList.totalElements" :page-size="pageSize"
|
|
|
:current="nowPage" @childEvent="listenPage"></page>
|
|
|
<div class="submit-area" v-if="bomList.content.length">
|
|
|
- <a class="delete-btn" @click="deleteItem()">删除</a>
|
|
|
+ <a class="modify-btn" @click="deleteItem()">删除</a>
|
|
|
<a class="modify-btn delete-btn" @click="submitBOM">确认发布</a>
|
|
|
</div>
|
|
|
<!--提示框-->
|
|
|
@@ -102,7 +120,7 @@
|
|
|
<!--<p style="line-height: 20px;margin-top: 10px;padding:0 10px">非常抱歉,目前暂无此品牌!<br>若直接前往“品牌申请”,我们将为您先开通寄售功能,待申请通过后再提交开店申请。</p>-->
|
|
|
<!--<p style="line-height: 20px;">前往<a @click="goBrandApply()" target="_blank" style="color: #5078CB">品牌申请 <i class="fa fa-arrow-right"></i></a></p>-->
|
|
|
<p><img src="/images/applyPurchase/check.png" alt="">发布成功</p>
|
|
|
- <p>其中<span>100</span>个求购型号有现货在售,您可前往“<span>买家中心-我的求购</span>”查询并直接购买</p>
|
|
|
+ <p>其中<span>{{onSaleNum}}</span>个求购型号有现货在售,您可前往“<span>买家中心-我的求购</span>”查询并直接购买</p>
|
|
|
<div>
|
|
|
<a @click="showRemindBox = false">继续发布</a>
|
|
|
<a href="/user#/seekPurchase">前往我的求购</a>
|
|
|
@@ -112,6 +130,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
|
|
|
+ }
|
|
|
import Page from '~components/common/page/pageComponent.vue'
|
|
|
export default {
|
|
|
data () {
|
|
|
@@ -120,13 +149,34 @@
|
|
|
nowPage: 1,
|
|
|
isCheckAll: false,
|
|
|
showRemindBox: false,
|
|
|
- modifyObj: {},
|
|
|
+ modifyObj: {
|
|
|
+ code: '',
|
|
|
+ brand: '',
|
|
|
+ unitPrice: '',
|
|
|
+ currency: 'RMB',
|
|
|
+ encapsulation: '',
|
|
|
+ produceDate: '',
|
|
|
+ amount: '',
|
|
|
+ deadline: ''
|
|
|
+ },
|
|
|
pickerOptions: {
|
|
|
disabledDate (time) {
|
|
|
// 大于等于今天 小于三个月后
|
|
|
return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ similarCode: [],
|
|
|
+ similarBrand: [],
|
|
|
+ validObj: {
|
|
|
+ code: true,
|
|
|
+ brand: true,
|
|
|
+ unitPrice: true,
|
|
|
+// encapsulation: true,
|
|
|
+// produceDate: true,
|
|
|
+ amount: true,
|
|
|
+ deadline: true
|
|
|
+ },
|
|
|
+ onSaleNum: 0
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
@@ -134,10 +184,16 @@
|
|
|
},
|
|
|
computed: {
|
|
|
bomList () {
|
|
|
+ let _this = this
|
|
|
let list = this.$store.state.applyPurchase.bomMaterial.bomList.data
|
|
|
for (let i = 0; i < list.content.length; i++) {
|
|
|
- list.content[i].checked = false
|
|
|
- list.content[i].active = false
|
|
|
+ _this.$set(list.content[i], 'checked', false)
|
|
|
+ _this.$set(list.content[i], 'active', false)
|
|
|
+// list.content[i].checked = false
|
|
|
+// list.content[i].active = false
|
|
|
+// if (!list.content[i].code || list.content[i].brand || !list.content[i].deadline || !this.isValidDate(list.content[i].deadline)) {
|
|
|
+// _this.validList = false
|
|
|
+// }
|
|
|
}
|
|
|
return list
|
|
|
},
|
|
|
@@ -147,17 +203,36 @@
|
|
|
},
|
|
|
filters: {
|
|
|
date: function (input) {
|
|
|
- const d = new Date(input)
|
|
|
- const year = d.getFullYear()
|
|
|
- const monthTemp = d.getMonth() + 1
|
|
|
- const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
|
|
|
- const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
|
|
|
- return year + '-' + month + '-' + day
|
|
|
+ if (input) {
|
|
|
+ const d = new Date(input)
|
|
|
+ const year = d.getFullYear()
|
|
|
+ const monthTemp = d.getMonth() + 1
|
|
|
+ const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
|
|
|
+ const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
|
|
|
+ return year + '-' + month + '-' + day
|
|
|
+ } else {
|
|
|
+ return null
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ initModifyObj: function () {
|
|
|
+ this.modifyObj = {
|
|
|
+ code: '',
|
|
|
+ brand: '',
|
|
|
+ unitPrice: '',
|
|
|
+ currency: 'RMB',
|
|
|
+ encapsulation: '',
|
|
|
+ produceDate: '',
|
|
|
+ amount: '',
|
|
|
+ deadline: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
listenPage: function (page) {
|
|
|
this.nowPage = page
|
|
|
+ this.reloadData()
|
|
|
+ },
|
|
|
+ reloadData: function () {
|
|
|
this.$store.dispatch('applyPurchase/loadBOMMaterialList', {bomId: this.$route.params.id, page: this.nowPage, count: this.pageSize})
|
|
|
},
|
|
|
submitBOM: function () {
|
|
|
@@ -208,8 +283,15 @@
|
|
|
for (let i = 0; i < this.bomList.content.length; i++) {
|
|
|
this.bomList.content[i].active = false
|
|
|
}
|
|
|
+// this.$set(this.bomList.content[index], 'active', true)
|
|
|
this.bomList.content[index].active = true
|
|
|
- this.modifyObj = this.bomList.content[index]
|
|
|
+ let _this = this
|
|
|
+ this.initModifyObj()
|
|
|
+ for (let attr in this.bomList.content[index]) {
|
|
|
+ _this.$set(_this.modifyObj, attr, _this.bomList.content[index][attr])
|
|
|
+// _this.modifyObj[attr] = _this.bomList.content[index][attr]
|
|
|
+ }
|
|
|
+// this.modifyObj = this.bomList.content[index]
|
|
|
this.modifyObj.deadline = this.getDate(this.bomList.content[index].deadline)
|
|
|
},
|
|
|
cancelModify: function (index) {
|
|
|
@@ -224,19 +306,37 @@
|
|
|
return year + '-' + month + '-' + day
|
|
|
},
|
|
|
submitModify: function (index) {
|
|
|
- this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
|
|
|
- .then(response => {
|
|
|
- if (response.data.success) {
|
|
|
- this.listenPage(1)
|
|
|
- this.$message.success('修改成功')
|
|
|
- this.bomList.content[index].active = false
|
|
|
- } else {
|
|
|
- this.$message.error('修改失败')
|
|
|
+ let checkValid = this.checkAll()
|
|
|
+ if (this.getSingleValidInfo(this.modifyObj) && checkValid) {
|
|
|
+ this.$http.put('/seek/updateSeekPurchaseByBatch', this.modifyObj)
|
|
|
+ .then(response => {
|
|
|
+ if (response.data.success) {
|
|
|
+ this.reloadData()
|
|
|
+ this.$message.success('修改成功')
|
|
|
+ this.onSaleNum = response.data.data
|
|
|
+// this.bomList.content[index].active = false
|
|
|
+ } else {
|
|
|
+ this.$message.error('修改失败')
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ console.log(err)
|
|
|
+ this.$message.error('系统错误')
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (!checkValid) {
|
|
|
+ if (!this.validObj.code) {
|
|
|
+ this.$message.error('型号不能为空')
|
|
|
+ } else if (!this.validObj.brand) {
|
|
|
+ this.$message.error('品牌不能为空')
|
|
|
+ } else if (!this.validObj.deadline) {
|
|
|
+ this.$message.error('截止日期不能为空')
|
|
|
+ } else if (!this.validObj.amount || !this.validObj.unitPrice) {
|
|
|
+ this.$message.error('请输入正确的数值')
|
|
|
}
|
|
|
- }, err => {
|
|
|
- console.log(err)
|
|
|
- this.$message.error('系统错误')
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ this.$message.error('请完善信息')
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
deleteItem: function (index) {
|
|
|
if (!index) {
|
|
|
@@ -272,6 +372,94 @@
|
|
|
console.log(err)
|
|
|
this.$message.error('系统错误')
|
|
|
})
|
|
|
+ },
|
|
|
+ isValidTime: function (time) {
|
|
|
+ let now = new Date().getTime()
|
|
|
+ return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 90)
|
|
|
+ },
|
|
|
+ isValidDate: function (date) {
|
|
|
+ let now = new Date().getTime()
|
|
|
+ let time = new Date(date).getTime()
|
|
|
+ return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 90)
|
|
|
+ },
|
|
|
+ getSimilarCode: function () {
|
|
|
+ this.$http.get('/search/similarComponents', {params: {keyword: this.modifyObj.code}})
|
|
|
+ .then(response => {
|
|
|
+ this.similarCode = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getSimilarBrand: function () {
|
|
|
+ this.$http.get('/search/similarBrands', {params: {keyword: this.modifyObj.brand}})
|
|
|
+ .then(response => {
|
|
|
+ this.similarBrand = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getSingleValidInfo: function (item) {
|
|
|
+ return item.code && item.brand && item.deadline && item.deadline !== 'NaN-NaN-NaN' && this.isValidDate(item.deadline)
|
|
|
+ },
|
|
|
+ checkCode: function () {
|
|
|
+ this.validObj.code = this.modifyObj.code && this.modifyObj.code !== ''
|
|
|
+ return this.validObj.code
|
|
|
+ },
|
|
|
+ checkBrand: function () {
|
|
|
+ this.validObj.brand = this.modifyObj.brand && this.modifyObj.brand !== ''
|
|
|
+ return this.validObj.brand
|
|
|
+ },
|
|
|
+ checkUnitPrice: function () {
|
|
|
+ this.validObj.unitPrice = (!this.modifyObj.unitPrice || this.modifyObj.unitPrice === '') ? true : this.modifyObj.unitPrice > 0 && this.modifyObj.unitPrice < 100000000
|
|
|
+ return this.validObj.unitPrice
|
|
|
+ },
|
|
|
+// checkEncapsulation: function () {
|
|
|
+// this.validObj.encapsulation = this.applyObj.encapsulation && this.applyObj.encapsulation !== ''
|
|
|
+// },
|
|
|
+// checkProduceDate: function () {
|
|
|
+// this.validObj.produceDate = this.applyObj.produceDate && this.applyObj.produceDate !== ''
|
|
|
+// },
|
|
|
+ checkAmount: function () {
|
|
|
+ this.validObj.amount = (!this.modifyObj.amount || this.modifyObj.amount === '') ? true : this.modifyObj.amount > 0 && this.modifyObj.amount < 100000000
|
|
|
+ return this.validObj.amount
|
|
|
+ },
|
|
|
+ checkAll: function () {
|
|
|
+ return this.checkCode() && this.checkBrand() && this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
|
|
|
+ },
|
|
|
+ checkDeadline: function () {
|
|
|
+ this.validObj.deadline = Boolean(this.modifyObj.deadline)
|
|
|
+ return this.validObj.deadline
|
|
|
+ },
|
|
|
+ onUnitPriceInput: function () {
|
|
|
+ let price = this.modifyObj.unitPrice
|
|
|
+ if (price >= 10000) {
|
|
|
+ this.modifyObj.unitPrice = price.substring(0, 4)
|
|
|
+ } else if (price.indexOf('.') > -1) {
|
|
|
+ let arr = price.split('.')
|
|
|
+ if (arr[0].length > 4) {
|
|
|
+ this.modifyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
|
|
|
+ } else if (arr[1].length > 6) {
|
|
|
+ this.modifyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onProduceDateChange: function () {
|
|
|
+// console.log(getRealLen(this.modifyObj.produceDate))
|
|
|
+ if (this.modifyObj.produceDate && getRealLen(this.modifyObj.produceDate) > 12) {
|
|
|
+ console.log(this.modifyObj.produceDate.substring(0, this.modifyObj.produceDate.length - 1))
|
|
|
+ this.modifyObj.produceDate = this.modifyObj.produceDate.substring(0, this.modifyObj.produceDate.length - 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onEncapsulationChange: function () {
|
|
|
+ if (this.modifyObj.encapsulation && getRealLen(this.modifyObj.encapsulation) > 20) {
|
|
|
+ this.modifyObj.encapsulation = this.modifyObj.encapsulation.substring(0, this.modifyObj.encapsulation.length - 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCodeChange: function () {
|
|
|
+ if (this.modifyObj.code && getRealLen(this.modifyObj.code) > 30) {
|
|
|
+ this.modifyObj.code = this.modifyObj.code.substring(0, this.modifyObj.code.length - 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onBrandChange: function () {
|
|
|
+ if (this.modifyObj.brand && getRealLen(this.modifyObj.brand) > 20) {
|
|
|
+ this.modifyObj.brand = this.modifyObj.brand.substring(0, this.modifyObj.brand.length - 1)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -328,6 +516,14 @@
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
+ position: relative;
|
|
|
+ font-size: 12px;
|
|
|
+ div.red-text {
|
|
|
+ line-height: normal;
|
|
|
+ position: absolute;
|
|
|
+ left: 42px;
|
|
|
+ top: 49px;
|
|
|
+ }
|
|
|
&.operate {
|
|
|
a {
|
|
|
display: block;
|
|
|
@@ -337,6 +533,7 @@
|
|
|
text-align: center;
|
|
|
border-radius: 3px;
|
|
|
margin: 0 auto 4px;
|
|
|
+ font-size: 14px;
|
|
|
&.submit-btn {
|
|
|
border: 1px solid #f64900;
|
|
|
color: #fff;
|
|
|
@@ -360,6 +557,9 @@
|
|
|
border: 1px solid #b5b5b5;
|
|
|
text-align: center;
|
|
|
padding: 0 5px;
|
|
|
+ &.error {
|
|
|
+ border-color: #f4645f !important;
|
|
|
+ }
|
|
|
}
|
|
|
&:nth-child(2) {
|
|
|
input {
|
|
|
@@ -420,6 +620,7 @@
|
|
|
.modify-btn {
|
|
|
border: 1px solid #3c7cf5;
|
|
|
color: #3c7cf5;
|
|
|
+ background: #fff;
|
|
|
}
|
|
|
.delete-btn {
|
|
|
border: 1px solid #3c7cf5;
|