| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <template>
- <view>
- <!-- 触发区域 -->
- <view class="remark-action" @click="openRemarkModal">
- <text :class="{ placeholder: !value }">{{ value || placeholder }}</text>
- <text class="iconfont iconxiangyou icon-arrow-right"></text>
- </view>
- <!-- 备注输入弹窗 -->
- <view class="remark-modal" v-if="showRemarkModal" @click="closeRemarkModal">
- <view class="modal-content" @click.stop>
- <view class="modal-header">
- <text class="modal-title">{{ modalTitle }}</text>
- </view>
- <view class="modal-body">
- <textarea
- v-model="tempRemark"
- :placeholder="placeholder"
- :maxlength="maxLength"
- :auto-height="true"
- class="remark-textarea"
- />
- <view class="char-count">{{ tempRemark.length }}/{{ maxLength }}</view>
- </view>
- <view class="modal-footer">
- <button class="modal-btn cancel-btn" @click="closeRemarkModal">取消</button>
- <button class="modal-btn confirm-btn" @click="confirmRemark">确认</button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'DeliveryInput',
- props: {
- value: {
- type: String,
- default: ''
- },
- placeholder: {
- type: String,
- default: '这里写跑腿备注'
- },
- modalTitle: {
- type: String,
- default: '填写备注信息'
- },
- maxLength: {
- type: Number,
- default: 200
- }
- },
- data() {
- return {
- showRemarkModal: false,
- tempRemark: ''
- };
- },
- methods: {
- openRemarkModal() {
- // 打开弹窗时,将当前备注内容赋值给临时变量
- this.tempRemark = this.value;
- this.showRemarkModal = true;
- },
- closeRemarkModal() {
- this.showRemarkModal = false;
- this.tempRemark = '';
- },
- confirmRemark() {
- // 更新备注
- this.$emit('input', this.tempRemark);
- // 关闭弹窗
- this.showRemarkModal = false;
- this.tempRemark = '';
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .remark-action {
- color: #3385FF;
- display: flex;
- align-items: center;
- font-size: 28upx;
- flex: 1;
- justify-content: flex-end;
-
- text {
- color: #333333;
- margin-right: 8upx;
-
- &.placeholder {
- color: #999999;
- }
- }
- }
- /* 备注输入弹窗 */
- .remark-modal {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- .modal-content {
- width: 600upx;
- background-color: white;
- border-radius: 16upx;
- overflow: hidden;
- }
- .modal-header {
- padding: 30upx 30upx 20upx;
- border-bottom: 1upx solid #f0f0f0;
- .modal-title {
- font-size: 32upx;
- font-weight: bold;
- color: #333333;
- }
- }
- .modal-body {
- padding: 30upx;
- .remark-textarea {
- width: 100%;
- min-height: 200upx;
- padding: 20upx;
- font-size: 28upx;
- color: #333333;
- background-color: #f9f9f9;
- border-radius: 8upx;
- border: 1upx solid #e0e0e0;
- box-sizing: border-box;
- }
- .char-count {
- margin-top: 10upx;
- font-size: 24upx;
- color: #999999;
- text-align: right;
- }
- }
- .modal-footer {
- display: flex;
- border-top: 1upx solid #f0f0f0;
- .modal-btn {
- flex: 1;
- height: 90upx;
- line-height: 90upx;
- font-size: 30upx;
- border: none;
- background-color: transparent;
- margin: 0;
- padding: 0;
- &.cancel-btn {
- color: #666666;
- border-right: 1upx solid #f0f0f0;
- }
- &.confirm-btn {
- color: #3385FF;
- font-weight: 500;
- }
- }
- }
- }
- </style>
|