|
|
@@ -4,22 +4,68 @@
|
|
|
<view class="item-remark-bar__text-wrap">
|
|
|
<text class="item-remark-bar__text">{{ displayText }}</text>
|
|
|
</view>
|
|
|
+ <text
|
|
|
+ v-if="showCancelBtn"
|
|
|
+ class="item-remark-bar__cancel"
|
|
|
+ @click.stop="onCancelRemark"
|
|
|
+ >取消</text>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { clearItemRemark } from '@/api/item'
|
|
|
+
|
|
|
export default {
|
|
|
name: 'ItemRemarkBar',
|
|
|
props: {
|
|
|
text: {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ itemId: {
|
|
|
+ type: [Number, String],
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: null
|
|
|
+ },
|
|
|
+ cancelable: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
displayText() {
|
|
|
const t = this.text == null ? '' : String(this.text).trim()
|
|
|
return t
|
|
|
+ },
|
|
|
+ showCancelBtn() {
|
|
|
+ return this.cancelable && !!this.itemId
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onCancelRemark() {
|
|
|
+ const id = this.itemId
|
|
|
+ if (!id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$util.confirmModal({ content: '确定取消备注?' }, () => {
|
|
|
+ clearItemRemark({ id }).then(res => {
|
|
|
+ if (res.code == 1) {
|
|
|
+ if (this.info) {
|
|
|
+ this.$set(this.info, 'itemRemark', '')
|
|
|
+ }
|
|
|
+ this.$emit('cleared', id)
|
|
|
+ uni.showToast({
|
|
|
+ title: res.msg || '已取消备注',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ } else if (res.msg) {
|
|
|
+ this.$msg(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -65,4 +111,13 @@ export default {
|
|
|
white-space: nowrap;
|
|
|
text-overflow: ellipsis;
|
|
|
}
|
|
|
+.item-remark-bar__cancel {
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 26upx;
|
|
|
+ color: #3385ff;
|
|
|
+ line-height: 48upx;
|
|
|
+ padding-left: 12upx;
|
|
|
+ margin-right: 10upx;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
</style>
|