dev01 1 year ago
parent
commit
1ea047d07a

+ 10 - 9
src/actions/increase.js

@@ -1,14 +1,15 @@
-import { } from '@constants/increase'
-import { API_HOME, } from '@constants/api'
+import { REPORT_CREST } from '@constants/increase'
+import { API_USER_REPORTDETAIL, } from '@constants/api'
 import { createAction } from '@utils/redux'
 
 /**
- * 首页数据
- * @param {*} payload
+ * 创建报告
+ * @param {*} payload 
  */
-// export const dispatchHome = payload => createAction({
-//   url: API_HOME,
-//   type: HOME_INFO,
-//   payload
-// })
+ export const creatReport = payload => createAction({
+  url: API_USER_REPORTDETAIL,
+  method: 'PUT',
+  type: REPORT_CREST,
+  payload
+})
 

+ 30 - 4
src/actions/template.js

@@ -1,5 +1,8 @@
-import { LIST_TEMPLATE, LIST_DELETE, LIST_DETAIL } from '@constants/user'
-import { API_USER_Template, API_USER_deleteTemplate, API_USER_DETAIL } from '@constants/api'
+import { LIST_TEMPLATE, LIST_DELETE, LIST_DETAIL, LIST_UPDATE } from '@constants/user'
+import {
+  API_USER_Template, API_USER_DELETE,
+  API_USER_DETAIL, API_USER_AEADDREPORTS, API_USER_UPDATE
+} from '@constants/api'
 import { createAction } from '@utils/redux'
 
 /**
@@ -17,7 +20,7 @@ export const getList = payload => createAction({
  * @param {*} payload 
  */
 export const deleteTemplate = payload => createAction({
-  url: API_USER_deleteTemplate + `/${payload.id}`,
+  url: API_USER_DELETE + `/${payload.id}`,
   method: 'DELETE',
   type: LIST_DELETE,
 })
@@ -31,4 +34,27 @@ export const reportTemplate = payload => createAction({
   url: API_USER_DETAIL + `/${payload.id}`,
   method: 'GET',
   type: LIST_DETAIL,
-})
+})
+
+/**
+ * 查询关联企业
+ * @param {*} payload 
+ */
+export const selcompany = payload => createAction({
+  url: API_USER_AEADDREPORTS + `/${payload.id}`,
+  method: 'GET',
+  type: LIST_DETAIL,
+})
+
+
+/**
+ * 模板编辑
+ * @param {*} payload
+ */
+export const updateTemplate = payload => createAction({
+  url: API_USER_UPDATE,
+  method: 'PUT',
+  type: LIST_UPDATE,
+  payload
+})
+

BIN
src/assets/ricon.png


+ 13 - 11
src/components/imagePicker/index.js

@@ -6,6 +6,7 @@ import './index.scss'
 export default class ImagePicker extends Component {
   static defaultProps = {
     time: Date.parse(new Date()),
+    urls: HOST,
   }
 
   async componentWillReceiveProps(nextProps) {
@@ -22,7 +23,7 @@ export default class ImagePicker extends Component {
   }
 
   async handleUpload() {
-    const { num = 1, id, onChange } = this.props
+    const { api, num = 1, id, onChange, keyId } = this.props
     const token = await this.getStorage('token')
     Taro.chooseImage({
       count: num, // 最多选择多少张图片
@@ -54,15 +55,16 @@ export default class ImagePicker extends Component {
         }
         // 上传每张图片到服务器
         files.forEach((file) => {
+          const formData = {}
+          formData[keyId] = id
           Taro.uploadFile({
-            url: 'http://zhcq.jishutao.com/gw/user/logo', // 上传接口地址
+            url: HOST + api,// 上传接口地址
+            // url: 'http://zhcq.jishutao.com/gw/user/logo', 
             filePath: file,
             header: {
               'Authorization': token,
             },
-            formData: {
-              reportId: !!id && id,
-            },
+            formData,
             name: 'file', // 服务端接收的文件字段名
             success: (result) => {
               if (result.statusCode === 200) {
@@ -120,7 +122,7 @@ export default class ImagePicker extends Component {
     const { imageUrls } = this.state;
     const updatedUrls = [...imageUrls];
     let obj = {
-      url: "http://zhcq.jishutao.com/gw/user/logo" + `/${this.props.id}`,
+      url: HOST + this.props.api + `/${this.props.id}`,
       method: 'DELETE',
       payload: {},
     }
@@ -131,9 +133,9 @@ export default class ImagePicker extends Component {
   }
 
   handlePreview(index) {
-    const { id, time } = this.props
+    const { api, id, time } = this.props
     const { imageUrls, token } = this.state;
-    const urls = imageUrls.map((url) => `http://zhcq.jishutao.com/gw/user/logo/${id}?token=${token}&t=${time}`);
+    const urls = imageUrls.map((url) => HOST + api + `/${id}?token=${token}&t=${time}`);
     Taro.previewImage({
       current: urls[index],
       urls,
@@ -142,16 +144,16 @@ export default class ImagePicker extends Component {
 
   render() {
     const { imageUrls = [], token } = this.state
-    const { time, id, num = 1 } = this.props
+    const { api, time, id, num = 1 } = this.props
     return (
       <View className='upload'>
         {imageUrls && imageUrls.map((url, index) => (
           <View className='upload-item' key={index}>
             <Image
               className='upload-item-img'
-              src={`http://zhcq.jishutao.com/gw/user/logo/${id}?token=${token}&t=${time}`}
+              src={HOST + api + `/${id}?token=${token}&t=${time}`}
               mode='aspectFit'
-              // onClick={() => this.handlePreview(index)}
+            // onClick={() => this.handlePreview(index)}
             />
             <View className='upload-item-delete'
               onClick={this.handleDelete.bind(this, index)}

+ 4 - 8
src/constants/api.js

@@ -10,20 +10,16 @@ export const hostM = HOST_M
 // pic
 export const CDN = 'https://yanxuan.nosdn.127.net'
 
-// user
 export const API_USER_LOGIN = `${host}/gw/user/login` // 登录
 export const API_USER_Template= `${host}/gw/user/reportTemplate` // 模板列表
-export const API_USER_deleteTemplate= `${host}/gw/user/reportTemplate` // 删除模板
-
-
-// list 
-export const API_USER_REPORTS = `${host}/gw/user/reports` // 我的列表
+export const API_USER_DELETE= `${host}/gw/user/reportTemplate` // 删除模板
 export const API_USER_DETAIL = `${host}/gw/user/reportTemplate` // 模板详情
+export const API_USER_UPDATE = `${host}/gw/user/reportTemplate` // 模板编辑
 
+export const API_USER_REPORTS = `${host}/gw/user/reports` // 我的列表
 
-// report 
 export const API_USER_QUERY = `${host}/gw/user/company/query` // 获取企业列表
-export const API_USER_AEADDREPORTS = `${host}/gw/user/company` // 新增企业名称
+export const API_USER_AEADDREPORTS = `${host}/gw/user/company` // 新增企业名称  查看关联企业
 export const API_USER_REPORTDETAIL = `${host}/gw/user/report` // 报告详情
 export const API_USER_AL = `${host}/gw/user/ai/generate` // Al生成
 export const API_USER_SUBREPORT = `${host}/gw/user/report` // 报告保存

+ 1 - 1
src/constants/increase.js

@@ -1 +1 @@
-export const INCREASE_MENU = 'INCREASE_MENU'
+export const REPORT_CREST = 'REPORT_CREST'

+ 1 - 0
src/constants/user.js

@@ -5,6 +5,7 @@ export const USER_LOGOUT = 'USER_LOGOUT'
 export const LIST_TEMPLATE = 'LIST_TEMPLATE'
 export const LIST_DELETE = 'LIST_DELETE'
 export const LIST_DETAIL = 'LIST_DETAIL'
+export const LIST_UPDATE = 'LIST_UPDATE'
 
 export const REPORT_QUERY = 'REPORT_QUERY'
 export const REPORT_AEADD = 'REPORT_AEADD'

+ 40 - 22
src/pages/increase/increase.js

@@ -1,54 +1,72 @@
 import Taro, { canIUse, Component } from '@tarojs/taro'
 import { View, Picker, ScrollView } from '@tarojs/components'
-import { Loading } from '@components'
 import { connect } from '@tarojs/redux'
+import * as template from '@actions/template'
 import * as actions from '@actions/increase'
 import { getWindowHeight } from '@utils/style'
 import './increase.scss'
 
 const RECOMMEND_SIZE = 20
 
-// @connect(state => state.home, { ...actions })
+@connect(state => state.home, { ...actions, ...template })
 class Increase extends Component {
   config = {
     navigationBarTitleText: '生成报告'
   }
 
   state = {
-    selector: [{ key: "项目验收申请单", value: 1 },
-    { key: "立项报告模板", value: 2 },
-    { key: "高新认定模板", value: 3 },
-    { key: "空白模板", value: 0 },],
+    selector: [],
     loaded: false,
     loading: false,
     lastItemId: 0,
-    hasMore: true
+    hasMore: true,
+    selectorChecked: {},
   }
 
   componentDidMount() {
-    // NOTE 暂时去掉不适配的内容
-    // Taro.showToast({
-    //   title: '注意,由于严选小程序首页界面、接口大幅变动,暂时去掉不相符的部分,后续再跟进改动',
-    //   icon: 'none',
-    //   duration: 6000
-    // })
+    this.getData()
+  }
 
+  getData() {
+    let payload = {}
+    this.props.getList(payload).then((data) => {
+      let list = data.items
+      list.push({
+        id: null,
+        name: "空白模板"
+      })
+      this.setState({
+        loading: false,
+        selector: list,
+      })
+    }).catch(() => {
+      this.setState({ loading: false })
+    })
   }
 
 
   onChange = e => {
-    console.log(e.detail.value, "e===", e)
-    this.setState({
-      selectorChecked: this.state.selector[e.detail.value]
+    this.creatReports(this.state.selector[e.detail.value])
+  }
+
+  // 创建报告
+  creatReports(obj) {
+    const payload = {
+      templateId: obj.id,
+    }
+    this.props.creatReport(payload).then((data) => {
+      this.setState({
+        loading: false,
+      })
+      Taro.navigateTo({
+        url: "/pages/user/reportdetail?id=" + data
+      })
+    }).catch(() => {
+      this.setState({ loading: false })
     })
   }
 
   render() {
-    // if (!this.state.loaded) {
-    //   return <Loading />
-    // }
-
-    const { } = this.props
     return (
       <View className='home'>
         <ScrollView
@@ -61,7 +79,7 @@ class Increase extends Component {
             <View className='increase__item'>
               <Picker
                 mode='selector'
-                rangeKey="key"
+                rangeKey="name"
                 range={this.state.selector}
                 onChange={this.onChange}>
                 <View className='increase__item-buttom'>

+ 7 - 1
src/pages/list/itemlist.js

@@ -11,9 +11,15 @@ export default class ItemList extends Component {
       <View className='list'>
         {
           list.length == 0
-            ? <View>暂无</View>
+            ? <View className='list__no'>暂无数据</View>
             : list.map(item =>
               <View className='list__item' key={item.id}
+                onLongPress={() => {
+                  console.log("久按")
+                  // Taro.vibrateShort(() => {
+                  //   console.log("====", item.id)
+                  // })
+                }}
                 onClick={() => {
                   Taro.navigateTo({
                     url: "/pages/user/reportdetail?id=" + item.id

+ 10 - 0
src/pages/list/itemlist.scss

@@ -1,6 +1,16 @@
 .list {
   padding: 20px;
 
+  &__no{
+    // background: #fff;
+    border-radius: 10px;
+    text-align: center;
+    font-size: 36px;
+    width: 70%;
+    margin: 100px auto;
+    padding: 50px 0;
+  }
+
   &__item {
     display: flex;
     flex-direction: row;

+ 1 - 4
src/pages/list/list.js

@@ -14,7 +14,6 @@ class List extends Component {
   }
 
   state = {
-    loaded: false,
     loading: false,
     lastItemId: 0,
     hasMore: true,
@@ -74,11 +73,9 @@ class List extends Component {
 
 
   render() {
-    // if (!this.state.loaded) {
+    // if (this.state.loaded) {
     //   return <Loading />
     // }
-
-    const { } = this.props
     return (
       <View className='home'>
         <View className='home_head'>

+ 2 - 0
src/pages/user/reportdetail.js

@@ -465,6 +465,8 @@ class ReportDetail extends Component {
           <View className='home-item-tit'>企业LOGO</View>
           <ImagePicker
             id={data.id}
+            keyId="reportId"
+            api='/gw/user/logo'
             urls={data.logoPath}
             onChange={(path) => {
               let obj = data

+ 22 - 6
src/pages/user/template.js

@@ -3,18 +3,18 @@ import { View, Input, Picker, ScrollView, Button } from '@tarojs/components'
 import { Loading } from '@components'
 import { connect } from '@tarojs/redux'
 import * as actions from '@actions/template'
+import * as increase from '@actions/increase'
 import TemplateList from './templatelist'
 import { getWindowHeight } from '@utils/style'
 import './template.scss'
 
-@connect(state => state.home, { ...actions, })
+@connect(state => state.home, { ...actions, ...increase })
 class Template extends Component {
   config = {
     navigationBarTitleText: '模板管理'
   }
 
   state = {
-    loaded: false,
     loading: false,
     lastItemId: 0,
     hasMore: true,
@@ -68,6 +68,20 @@ class Template extends Component {
     })
   }
 
+  // 使用模板创建报告
+  creatReports = (obj) => {
+    const payload = {
+      templateId: obj.id,
+    }
+    this.props.creatReport(payload).then((data) => {
+      Taro.navigateTo({
+        url: "/pages/user/reportdetail?id=" + data
+      })
+    }).catch(() => {
+
+    })
+  }
+
   onChange = e => {
     this.setState({
       selectorChecked: this.state.selector[e.detail.value],
@@ -82,11 +96,9 @@ class Template extends Component {
 
 
   render() {
-    // if (!this.state.loaded) {
+    // if (this.state.loaded) {
     //   return <Loading />
     // }
-
-    const { } = this.props
     return (
       <View className='home'>
         <View className='home_head'>
@@ -114,7 +126,11 @@ class Template extends Component {
           onScrollToLower={this.getData}
           style={{ height: (getWindowHeight().substring(0, getWindowHeight().length - 2) - 55) + "px" }}
         >
-          <TemplateList list={this.state.dataList} deleteTemplate={(e) => { this.deleteTemplate(e) }} />
+          <TemplateList
+            list={this.state.dataList}
+            deleteTemplate={e => { this.deleteTemplate(e) }}
+            creatReports={e => { this.creatReports(e) }}
+          />
         </ScrollView>
       </View>
     )

+ 343 - 37
src/pages/user/templatedetail.js

@@ -3,11 +3,11 @@ import { View, Input, Picker, Label, Button } from '@tarojs/components'
 import { Loading } from '@components'
 import { connect } from '@tarojs/redux'
 import * as actions from '@actions/template'
-import { getWindowHeight } from '@utils/style'
+import * as report from '@actions/report'
 import ImagePicker from '../../components/imagePicker'
 import './templatedetail.scss'
 
-@connect(state => state.home, { ...actions, })
+@connect(state => state.home, { ...actions, ...report })
 class TemplateDetail extends Component {
 
   config = {
@@ -15,14 +15,16 @@ class TemplateDetail extends Component {
   }
 
   state = {
+    loading: true,
     selector: [
       { name: "文本项", type: "text" },
       { name: "日期项", type: "date" },
       { name: "起止时间", type: "dateRange" },
     ],
-
     visible: "",
-    data: {},
+    data: {
+      tags: [],
+    },
     metadata: [],
     chapterType: [
       { title: "立项背景与意义", key: "BACKGROUND", keywords: ['必要性'] },
@@ -36,14 +38,19 @@ class TemplateDetail extends Component {
       { title: "项目风险分析和对策", key: "RISK", keywords: ['风险分析', '风险对策'] },
       { title: "自定义章节", key: "USER_DEFINED", keywords: [] },
     ],
-    chapterData: [],
-
+    chapters: [],
+    aeList: [],
+    name: "",
+    newvb: false,
+    popup: false,
   }
 
   componentDidMount() {
-    // this.getData()
+    this.getData()
+    this.getQuery()
   }
 
+  // 详情
   getData() {
     this.setState({ loading: true })
     let payload = {
@@ -52,14 +59,49 @@ class TemplateDetail extends Component {
     this.props.reportTemplate(payload).then((data) => {
       this.setState({
         loading: false,
-        data: data.data,
+        data: data,
+        metadata: data.metadata,
+        chapters: data.chapters,
+      }, () => {
+        !!data.companyId && this.getCompany(data.companyId)
       })
     }).catch(() => {
+      // setInterval(function () {
+      //   Taro.navigateBack()
+      // }, 800)
       this.setState({ loading: false })
     })
+  }
 
+  // 获取企业列表
+  getQuery() {
+    let payload = {
+      name: "",
+      size: 99,
+    }
+    this.props.query(payload).then((data) => {
+      this.setState({
+        aeList: data,
+      })
+    }).catch(() => {
+
+    })
   }
+  // 获取企业名
+  getCompany(id) {
+    const obj = this.state.data
+    let payload = {
+      id,
+    }
+    this.props.selcompany(payload).then((data) => {
+      obj.companyName = data.name
+      this.setState({
+        data: obj,
+      })
+    }).catch(() => {
 
+    })
+  }
   // 添加新项
   onChange = e => {
     this.setState({
@@ -68,16 +110,101 @@ class TemplateDetail extends Component {
       visible: "add"
     })
   }
-
+  // 阿拉伯数字转中文
+  numberToChinese(num) {
+    var arr1 = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');
+    var arr2 = new Array('', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿');//可继续追加更高位转换值
+    if (!num || isNaN(num)) {
+      return "零";
+    }
+    var english = num.toString().split("");
+    var result = "";
+    for (var i = 0; i < english.length; i++) {
+      var des_i = english.length - 1 - i;//倒序排列设值
+      result = arr2[i] + result;
+      var arr1_index = english[des_i];
+      result = arr1[arr1_index] + result;
+    }
+    //将【零千、零百】换成【零】 【十零】换成【十】
+    result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十');
+    //合并中间多个零为一个零
+    result = result.replace(/零+/g, '零');
+    //将【零亿】换成【亿】【零万】换成【万】
+    result = result.replace(/零亿/g, '亿').replace(/零万/g, '万');
+    //将【亿万】换成【亿】
+    result = result.replace(/亿万/g, '亿');
+    //移除末尾的零
+    result = result.replace(/零+$/, '');
+    //将【零一十】换成【零十】
+    //result = result.replace(/零一十/g, '零十');//貌似正规读法是零一十
+    //将【一十】换成【十】
+    result = result.replace(/^一十/g, '十');
+    return result;
+  }
+  // 字符串拼接
+  getTitleWithChineseNum(index, title) {
+    return this.numberToChinese(index + 1) + '、' + title
+  }
+  // 章节添加
   onChapterChange = e => {
-    let list = this.state.chapterData
-    list.push(this.state.chapterType[e.detail.value])
+    let list = this.state.chapters
+    let obj = this.state.chapterType[e.detail.value]
+    let data = {
+      chapterType: obj.key,
+      content: "",
+      fullTitle: this.getTitleWithChineseNum(list.length, obj.title),
+      keywords: obj.keywords,
+      title: obj.title,
+    }
+    list.push(data)
+    this.setState({
+      chapters: list
+    })
+  }
+  // 选中关联企业
+  onAeChange = e => {
+    const { aeList } = this.state
+    let obj = aeList[e.detail.value]
+    let list = this.state.data
+    list.companyName = obj.name
+    list.companyId = obj.id
+    this.setState({
+      data: list,
+    })
+  }
+  // 企业添加
+  onAeCancel = () => {
     this.setState({
-      chapterData: list
+      name: "",
+      newvb: false,
     })
   }
+  // 企业添加
+  onAeOk = () => {
+    if (!this.state.name) {
+      Taro.showToast({
+        title: "请输入新企业名称",
+        icon: 'none'
+      })
+      return
+    }
+    const payload = {
+      name: this.state.name,
+    }
+    this.props.company(payload).then((data) => {
+      let obj = this.state.data
+      obj.companyName = data.name
+      obj.companyId = data.id
+      this.setState({
+        data: obj,
+        newvb: false,
+      })
+    }).catch(() => {
 
+    })
 
+  }
+  // 添加新项弹窗
   onCancel = () => {
     this.setState({
       inputName: undefined,
@@ -90,7 +217,7 @@ class TemplateDetail extends Component {
       visible: "",
     })
   }
-
+  // 添加新项弹窗
   onOk = () => {
     const { visible, metadata, inputName, inputText, type, indx, dateSel, dataStart, dataEnd } = this.state
     // if (visible == "add") {
@@ -152,14 +279,81 @@ class TemplateDetail extends Component {
       })
     }
   }
+  // 修改章节名
+  onChapTitle = (i, e) => {
+    const data = this.state.chapters
+    data.forEach(function (item, index) {
+      if (index == i) {
+        item.title = e.detail.value
+      }
+    })
+    this.setState({
+      chapters: data
+    })
+  }
+  // 修改章节关键词
+  onChapKeywords = (i, e) => {
+    const data = this.state.chapters
+    data.forEach(function (item, index) {
+      if (index == i) {
+        let val = e.detail.value.replace(/[\uff0c]/g, ",")
+        item.keywords = val.split(",")
+      }
+    })
+    this.setState({
+      chapters: data
+    })
+  }
+  // 二级确认
+  toggleVisible = () => {
+    this.setState({
+      popup: !this.state.popup,
+    })
+  }
+  // 删除章节
+  delChap = () => {
+    const list = this.state.chapters
+    list.splice(this.state.delIndex, 1)
+    for (var i = 0; i < list.length; i++) {
+      list[i].fullTitle = this.getTitleWithChineseNum(i, list[i].title)
+    }
+    this.setState({
+      chapters: list
+    })
+    this.toggleVisible()
+  }
+  // 保存
+  onSubsmit = () => {
+    const { data, metadata, chapters } = this.state
+    if (!data.name) {
+      Taro.showToast({
+        title: "请填写报告模板名称!",
+        icon: 'none'
+      })
+      return
+    }
+    data.metadata = metadata
+    data.chapters = chapters
+    let payload = data
+    this.props.updateTemplate(payload).then((data) => {
+      Taro.showToast({
+        title: "保存成功",
+        icon: 'none'
+      })
+      setTimeout(function () {
+        Taro.navigateBack()
+      }, 400)
+    }).catch(() => {
+
+    })
+  }
 
 
   render() {
-    // if (!this.state.loaded) {
+    // if (this.state.loading) {
     //   return <Loading />
     // }
-
-    const { data, visible, metadata, type, chapterType, chapterData } = this.state
+    const { data, visible, metadata, type, chapterType, chapters, aeList } = this.state
     return (
       <View className='home'>
         <View className='home-item'>
@@ -167,23 +361,74 @@ class TemplateDetail extends Component {
           <Input
             value={data.name}
             className='home-item-val'
+            placeholder='请输入项目名称'
+            onChange={e => {
+              let obj = data
+              obj.name = e.detail.value
+              this.setState({
+                data: obj,
+              })
+            }}
           />
         </View>
         <View className='home-item'>
           <View className='home-item-tit'>报告模板标签</View>
+          <Input
+            value={data.tags.toString().replace(/,/g, ",")}
+            className='home-item-val'
+            placeholder='模板标签,输入逗号分割'
+            onChange={e => {
+              let obj = data
+              let val = e.detail.value.replace(/[\uff0c]/g, ",")
+              obj.tags = val.split(",")
+              this.setState({
+                data: obj,
+              })
+            }}
+          />
         </View>
         <View className='home-item'>
           <View className='home-item-tit'>关联企业</View>
+          <View className='home-item-vals'>
+            <Picker mode='selector' range={aeList} rangeKey="name"
+              onChange={this.onAeChange}
+            >
+              <View className='home-item-vals-txt'>{data.companyName || "请选择关联企业"}</View>
+            </Picker>
+            <View className='home-item-vals-bt'>
+              <Button size='mini' type='primary' onClick={() => { this.setState({ newvb: true }) }}>+新增企业</Button>
+            </View>
+          </View>
         </View>
         <View className='home-item'>
           <View className='home-item-tit'>企业LOGO</View>
-          <ImagePicker id={397} />
+          <ImagePicker
+            id={data.id}
+            keyId="templateId"
+            api='/gw/user/reportTemplate/logo'
+            urls={data.logoPath}
+            onChange={(path) => {
+              let obj = data
+              obj.logoPath = path
+              this.setState({
+                data: obj,
+              })
+            }}
+          />
         </View>
         <View className='home-item'>
           <View className='home-item-tit'>项目名称</View>
           <Input
             value={data.reportName}
             className='home-item-val'
+            placeholder='请输入项目名称'
+            onChange={e => {
+              let obj = data
+              obj.reportName = e.detail.value
+              this.setState({
+                data: obj,
+              })
+            }}
           />
         </View>
         {
@@ -202,7 +447,21 @@ class TemplateDetail extends Component {
                 })
               }}
             >
-              <View className='home-item-tit'>{item.name}</View>
+              <View className='home-item-tits'>
+                <View className='home-item-tits-txt'>{item.name}</View>
+                <View className='home-item-tits-bt'>
+                  <Button size='mini' type='warn'
+                    onClick={e => {
+                      e.stopPropagation()
+                      let list = this.state.metadata
+                      list.splice(index, 1)
+                      this.setState({
+                        metadata: list
+                      })
+                    }}
+                  >删除</Button>
+                </View>
+              </View>
               {item.type == "text" && <View className='home-item-val'>{item.value}</View>}
               {item.type == "date" && <View className='home-item-val'>{item.value}</View>}
               {item.type == "dateRange" && <View className='home-item-val'>{item.value.replace(" ", " → ")}</View>}
@@ -216,20 +475,40 @@ class TemplateDetail extends Component {
             <Button>+添加新项</Button>
           </Picker>
         </View>
-
+        <View className='home-line' />
         {
-          chapterData.map((item, index) =>
-            <View className='home-item' key={index}>
-              <Input
-                value={item.title}
-                className='home-item-tit'
-              />
+          chapters.map((item, index) =>
+            <View className='home-item' key={index} style={{ marginBottom: 10, }}>
+              <View className='home-item-tits'>
+                <Input
+                  value={item.title}
+                  className='home-item-tits-txt'
+                  style={{ borderBottom: "1px solid #d9d9d9" }}
+                  onChange={(e) => {
+                    this.onChapTitle(index, e)
+                  }}
+                />
+                <View className='home-item-tits-bt'>
+                  <Button size='mini' type='warn'
+                    onClick={e => {
+                      e.stopPropagation()
+                      this.setState({
+                        delIndex: index
+                      })
+                      this.toggleVisible()
+                    }}
+                  >删除</Button>
+                </View>
+              </View>
               <View className='home-item-text'>
                 <View>章节关键词:</View>
                 <Input
-                  value={item.keywords.toString()}
+                  value={item.keywords.toString().replace(/,/g, ",")}
                   className='home-item-text-val'
                   placeholder='输入逗号分割'
+                  onChange={(e) => {
+                    this.onChapKeywords(index, e)
+                  }}
                 />
               </View>
             </View>
@@ -237,23 +516,16 @@ class TemplateDetail extends Component {
         }
 
         <View className='home-item'>
-          <Picker mode='chapterType' range={chapterType} rangeKey="title"
+          <Picker mode='selector' range={chapterType} rangeKey="title"
             onChange={this.onChapterChange}
           >
             <Button>+添加章节</Button>
           </Picker>
         </View>
-
-
-        <View className='home-item'>
-          <View className='home-item-editor' contenteditable="true">请填写内容...</View>
+        <View className='home-item' style={{ marginTop: 60, paddingBottom: 30 }}>
+          <Button type='primary' onClick={this.onSubsmit}>保存</Button>
         </View>
-
-
-        <View className='home-item'>
-          <Button type='primary'>保存</Button>
-        </View>
-
+        {/* 新增项 */}
         {visible != "" &&
           <View className='mask'>
             <View className='count'>
@@ -317,6 +589,40 @@ class TemplateDetail extends Component {
               </View>
             </View>
           </View>}
+        {/* 新增企业 */}
+        {this.state.newvb &&
+          <View className='mask'>
+            <View className='count'>
+              <View className='title'>新增企业名称</View>
+              <View className='count_top'>
+                <Input
+                  value={this.state.name}
+                  className='count_top_input'
+                  placeholder='请输入新企业名称'
+                  onChange={e => { this.setState({ name: e.detail.value }) }}
+                />
+              </View>
+              <View className='count_foot'>
+                <Button onClick={this.onAeCancel}>取消</Button>
+                <Button style={{ marginTop: 0 }}
+                  onClick={this.onAeOk}
+                >确认</Button>
+              </View>
+            </View>
+          </View>}
+        {/* 二级确认 */}
+        {this.state.popup &&
+          <View className='mask'>
+            <View className='count'>
+              <View className='title' style={{ margin: "60px 0" }}>确认删除吗?</View>
+              <View className='count_foot'>
+                <Button onClick={this.toggleVisible}>取消</Button>
+                <Button style={{ marginTop: 0 }}
+                  onClick={this.delChap}
+                >确认</Button>
+              </View>
+            </View>
+          </View>}
       </View>
     )
   }

+ 7 - 12
src/pages/user/templatelist.js

@@ -12,7 +12,6 @@ export default class TemplateList extends Component {
     }
   }
 
-
   toggleVisible = () => {
     this.setState({
       visible: !this.state.visible,
@@ -30,12 +29,11 @@ export default class TemplateList extends Component {
 
   render() {
     const { list = [] } = this.props
-    const popupStyle = { transform: `translateY(${Taro.pxTransform(-100)})` }
     return (
       <View className='list'>
         {
           list.length == 0
-            ? <View>暂无</View>
+            ? <View className='list__no'>暂无数据</View>
             : list.map(item =>
               <View className='list__item' key={item.id}
                 onClick={() => {
@@ -46,18 +44,15 @@ export default class TemplateList extends Component {
               >
                 <View className='list__item__left'>
                   <View className='list__item__left-one'>{item.name}</View>
-                  {/* {
-                    !!item.metadata && item.metadata.length > 0 && item.metadata.map((t, x) =>
-                      <View className='list__item__left-two' key={x}>{t.name}:{t.value}</View>
-                    )
-                  } */}
-                  {/* <View className='list__item__left-two'>标签:{item.tags}
-                  
-                  </View> */}
                   <View className='list__item__left-two'>创建时间:{item.createAt}</View>
                   <View className='list__item__left-two'>更新时间:{item.updateAt}</View>
                   <View className='list__item__left-bottom'>
-                    <View className='list__item__left-bottom_g'>使用该模板</View>
+                    <View className='list__item__left-bottom_g'
+                      onClick={e => {
+                        e.stopPropagation()
+                        this.props.creatReports(item)
+                      }}
+                    >使用该模板</View>
                     <View className='list__item__left-bottom_d'
                       onClick={e => {
                         e.stopPropagation()

+ 10 - 0
src/pages/user/templatelist.scss

@@ -1,6 +1,16 @@
 .list {
   padding: 20px;
 
+  &__no{
+    // background: #fff;
+    border-radius: 10px;
+    text-align: center;
+    font-size: 36px;
+    width: 70%;
+    margin: 100px auto;
+    padding: 50px 0;
+  }
+
   &__item {
     display: flex;
     flex-direction: row;

+ 5 - 14
src/pages/user/user.js

@@ -1,10 +1,9 @@
 import Taro, { Component } from '@tarojs/taro'
-import { View, Text, ScrollView } from '@tarojs/components'
-import { Loading } from '@components'
-import { connect } from '@tarojs/redux'
-import * as actions from '@actions/user'
+import { View, Text, ScrollView, Image } from '@tarojs/components'
 import { getWindowHeight } from '@utils/style'
+import icon from '../../assets/ricon.png'
 import './user.scss'
+
 // @connect(state => state.home, { ...actions, })
 class User extends Component {
   config = {
@@ -12,10 +11,7 @@ class User extends Component {
   }
 
   state = {
-    loaded: false,
-    loading: false,
-    lastItemId: 0,
-    hasMore: true
+
   }
 
   componentDidMount() {
@@ -24,11 +20,6 @@ class User extends Component {
 
 
   render() {
-    // if (!this.state.loaded) {
-    //   return <Loading />
-    // }
-
-    const { } = this.props
     return (
       <View className='home'>
         <ScrollView
@@ -44,7 +35,7 @@ class User extends Component {
             }}
           >
             我的模板
-            <Text>></Text>
+            <Image className='item-icon' src={icon} />
           </View>
           <View className='exit'
             onClick={() => {

+ 6 - 0
src/pages/user/user.scss

@@ -12,6 +12,12 @@
   flex-direction: row;
   align-items: center;
   justify-content: space-between;
+  font-size: 40px;
+
+  &-icon{
+    width: 40px;
+    height: 40px;
+  }
 
 }
 

+ 0 - 1
src/utils/request.js

@@ -78,7 +78,6 @@ export default async function fetch(options) {
 
     return data
   }).catch((err) => {
-    console.log("err==", err)
     if (showToast) {
       Taro.showToast({
         title: err && err.status === 200004 ? '登录失效' : err.msg,