<template>
  <view class="transportationProcessRemarks">
    <view class="uni-list-cell">
      <view class="uni-list-cell-left">
        备注：
      </view>
      <view class="uni-list-cell-db">
        <textarea maxlength="100" class="textarea" v-model="logRemarks" :placeholder="logPrompts" />
      </view>
    </view>
    <view class="uni-list-cell" v-if="customRemarks.length">
      <view class="uni-list-cell-left">
        快捷输入：
      </view>
      <view class="uni-list-cell-db">
        <span class="addRemarks" v-for="(item, i) of customRemarks" :key="i" @click="addRemarks(item)">【{{ item }}】</span>
      </view>
    </view>
    <view class="foot_btn_spe">
      <view class="btn1" @click="postWorkerOrder()">完成工单</view>
      <view class="btn3" @click="goBack">返回</view>
    </view>
  </view>
</template>

<script>
  import * as commonFun from '../../tools/commonFun.js';
  import {
    get,
    post,
    webHandle
  } from "../../http/http.js";
  export default {
    data() {
      return {
        currentCode: '', //当前拍照使用的科室二维码
        options: {},
        logRemarks: '',
        logPrompts: '',
        customRemarks: [],
        //动作列表
        actions: [],
        //图片列表
        imageValue: [],
      };
    },
    methods:{
      // 返回
      goBack() {
        uni.navigateBack();
      },
      // 添加备注
      addRemarks(item) {
        this.logRemarks += item;
      },
      // 完成工单
      postWorkerOrder(){
        if(!this.logRemarks.trim()){
          uni.showToast({
            icon: "none",
            title: "请填写备注！",
          });
          return;
        }
        let data = this.options.data;
        let accountObj = this.options.accountObj;
        console.log(commonFun)
        commonFun[this.options.funName](this, this.options.data, this.options.accountObj);
      },
    },
    onLoad(options) {
      uni.hideLoading();
      options.data && (options.data = JSON.parse(options.data));
      options.accountObj && (options.accountObj = JSON.parse(options.accountObj));
      options.actions && (options.actions = JSON.parse(options.actions));
      options.imageValue && (options.imageValue = JSON.parse(options.imageValue));
      this.options = options;
      console.log(options);
      // 待送达
      if(options.data.taskType.associationType.value == 'other' && options.data.gdState.value == 5){
        let carryingCourses = options.data.taskType.carryingCourses[1];
        this.logPrompts = carryingCourses.logPrompts || "请填写备注,不超过100个字符";
        this.customRemarks = carryingCourses.logRemarks ? carryingCourses.logRemarks.split("$") : [];
        this.currentCode = options.currentCode;
        this.actions = options.actions;
        this.imageValue = options.imageValue;
      }
    }
  }
</script>

<style lang="less" scoped>
.transportationProcessRemarks{
  padding: 16rpx;
  .textarea{
    width: 100%;
    border: 2rpx solid #d9d9d9;
  }
  .foot_btn_spe {
    width: 100%;
    position: fixed;
    bottom: 30rpx;
    left: 0;
    line-height: 88rpx;
    height: 88rpx;
    text-align: center;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  
    &::after {
      content: '';
      flex: 1;
    }
  
    view {
      height: 88rpx;
      width: 48%;
      margin: 0 1%;
      background-image: linear-gradient(to right, #72c172, #3bb197);
      color: #fff;
      border-radius: 8rpx;
      font-size: 32rpx;
      margin-top: 16rpx;
    }
  }
}
</style>
