<template>
  <view class="container">
    <u-divider
      text="专项整治行动"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <u-cell-group>
      <u-cell title="专项行动名称" :value="info.ACTIVITY_TASK_NAME" />
      <!--      <u-cell title="行动类型" :value="info.ACTIVITY_TASK_TYPE_NAME" />-->
      <u-cell title="工作任务">
        <!--        <template #label>{{ info.ACTIVITY_TASK }}</template>-->
        <template #label>
          <view class="ql-editor">
            <u-parse :content="info.ACTIVITY_TASK"></u-parse>
          </view>
        </template>
      </u-cell>
      <!--      <u-cell title="包联工委管委领导" :value="info.ACTIVITY_TASK_LEADER" />-->
      <u-cell
        title="工作周期"
        :value="info.ACTIVITY_TIME_BEGIN + '至' + info.ACTIVITY_TIME_END"
      />
      <u-cell title="附件">
        <template #label>
          <u-row v-for="(item, i) in info.filesList" :key="item.FILEPATH">
            <view @click="showFile(item)">{{ i + 1 + "." + item.NAME }}</view>
          </u-row>
        </template>
      </u-cell>
    </u-cell-group>
    <u-divider
      text="责任单位"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <u-cell-group v-for="(item, index) in info.deptList" :key="index">
      <!--        <u-cell-->
      <!--          class="cell_tit"-->
      <!--          title=""-->
      <!--          :value="item.DEPARTMENT_TYPE === '1' ? '牵头单位' : '协调联动单位'"-->
      <!--        />-->
      <u-cell title="单位名称" :value="item.DEPARTMENT_NAME" />
      <u-cell title="联系人" :value="item.CONTACT_NAME" />
      <u-cell title="具体工作人员">
        <template #label>
          <u-row>
            <view
              v-for="(user, i) in item.userList"
              :key="user.SPECIAL_RECTIFICATION_ACTIVITY_TASK_USER_ID"
            >
              {{ i > 0 ? "," + user.USER_NAME : user.USER_NAME }}
            </view>
          </u-row>
        </template>
      </u-cell>
    </u-cell-group>
  </view>
</template>

<script>
import { getSpecialRectificationTaskView } from "@/api";

export default {
  data() {
    return {
      info: {
        filesList: [],
      },
    };
  },
  onLoad(query) {
    this.fnGetData(query.SPECIAL_RECTIFICATION_ACTIVITY_TASK_ID);
  },
  methods: {
    async fnGetData(SPECIAL_RECTIFICATION_ACTIVITY_TASK_ID) {
      const resData = await getSpecialRectificationTaskView({
        SPECIAL_RECTIFICATION_ACTIVITY_TASK_ID,
      });
      for (let i = 0; i < resData.pd.filesList.length; i++) {
        resData.pd.filesList[i].FILEPATH =
          this.$filePath + resData.pd.filesList[i].FILEPATH;
      }
      this.info = resData.pd;
    },
    showFile(item) {
      uni.showLoading({
        title: "加载中...",
      }); // 加载中动画
      uni.downloadFile({
        url: item.FILEPATH,
        success: (res) => {
          uni.hideLoading(); // 结束加载中动画
          uni.openDocument({
            filePath: res.tempFilePath,
            success: function () {},
          });
        },
      });
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  padding: 20upx;
}
.u-icon {
  justify-content: center;
}
titleStyle {
  font-weight: bold;
}
.cell_tit {
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
