|
|
@@ -0,0 +1,154 @@
|
|
|
+<template>
|
|
|
+ <view class="item-remark-bar" v-if="displayText">
|
|
|
+ <text class="item-remark-bar__label">备注</text>
|
|
|
+ <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
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ remarkHidden: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ remarkSource() {
|
|
|
+ if (this.info && this.info.itemRemark != null && this.info.itemRemark !== undefined) {
|
|
|
+ return this.info.itemRemark
|
|
|
+ }
|
|
|
+ return this.text
|
|
|
+ },
|
|
|
+ displayText() {
|
|
|
+ if (this.remarkHidden) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ const t = this.remarkSource == null ? '' : String(this.remarkSource).trim()
|
|
|
+ return t
|
|
|
+ },
|
|
|
+ showCancelBtn() {
|
|
|
+ return this.cancelable && !!this.itemId
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ text() {
|
|
|
+ this.resetRemarkHidden()
|
|
|
+ },
|
|
|
+ 'info.itemRemark'() {
|
|
|
+ this.resetRemarkHidden()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ resetRemarkHidden() {
|
|
|
+ const t = this.remarkSource == null ? '' : String(this.remarkSource).trim()
|
|
|
+ if (t) {
|
|
|
+ this.remarkHidden = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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.remarkHidden = true
|
|
|
+ this.$emit('cleared', id)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$forceUpdate()
|
|
|
+ })
|
|
|
+ uni.showToast({
|
|
|
+ title: res.msg || '已取消备注',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ } else if (res.msg) {
|
|
|
+ this.$msg(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.item-remark-bar {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+ width: 100%;
|
|
|
+ height: 48upx;
|
|
|
+ max-height: 48upx;
|
|
|
+ margin-top: 4upx;
|
|
|
+ margin-bottom: 4upx;
|
|
|
+ padding: 0 10upx;
|
|
|
+ background: #fff8f2;
|
|
|
+ border-left: 5upx solid #ff8c3a;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.item-remark-bar__label {
|
|
|
+ font-size: 26upx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #ff8c3a;
|
|
|
+ line-height: 48upx;
|
|
|
+ margin-right: 8upx;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+.item-remark-bar__text-wrap {
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+ height: 48upx;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.item-remark-bar__text {
|
|
|
+ display: block;
|
|
|
+ font-size: 28upx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #ff2842;
|
|
|
+ line-height: 48upx;
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+}
|
|
|
+.item-remark-bar__cancel {
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 26upx;
|
|
|
+ color: #3385ff;
|
|
|
+ line-height: 48upx;
|
|
|
+ padding-left: 12upx;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+</style>
|