|
@@ -40,7 +40,9 @@ class ReportDetail extends Component {
|
|
|
name: "",
|
|
|
newvb: false,
|
|
|
popup: false,
|
|
|
-
|
|
|
+ template: false,
|
|
|
+ name: '',
|
|
|
+ tags: [],
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
@@ -306,7 +308,7 @@ class ReportDetail extends Component {
|
|
|
data.forEach(function (item, index) {
|
|
|
if (index == i) {
|
|
|
let val = e.detail.value.replace(/[\uff0c]/g, ",")
|
|
|
- item.keywords = val.split(",")
|
|
|
+ item.keywords = !val ? [] : val.split(",")
|
|
|
}
|
|
|
})
|
|
|
this.setState({
|
|
@@ -344,7 +346,7 @@ class ReportDetail extends Component {
|
|
|
this.toggleVisible()
|
|
|
}
|
|
|
// 保存
|
|
|
- onSubsmit = () => {
|
|
|
+ onSubmit = () => {
|
|
|
const { data, metadata, chapters } = this.state
|
|
|
if (!data.companyId) {
|
|
|
Taro.showToast({
|
|
@@ -393,7 +395,44 @@ class ReportDetail extends Component {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
+ // 另存为模板
|
|
|
+ onReportTemplate = () => {
|
|
|
+ const { data, metadata, chapters, name, tags } = this.state
|
|
|
+ if (!this.state.name) {
|
|
|
+ Taro.showToast({
|
|
|
+ title: "请填写模板名称!",
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let payload = {
|
|
|
+ chapters,
|
|
|
+ companyId: data.companyId || 0,
|
|
|
+ id: 0,
|
|
|
+ logoPath: data.logoPath || '',
|
|
|
+ metadata,
|
|
|
+ name,
|
|
|
+ reportName: data.reportName || '',
|
|
|
+ tags,
|
|
|
+ }
|
|
|
+ this.props.onReportTemplate(payload).then((data) => {
|
|
|
+ this.onTemCancel()
|
|
|
+ Taro.showToast({
|
|
|
+ title: "模板保存成功",
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 取消
|
|
|
+ onTemCancel = () => {
|
|
|
+ this.setState({
|
|
|
+ name: '',
|
|
|
+ tags: [],
|
|
|
+ template: false,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
render() {
|
|
|
// if (!this.state.loaded) {
|
|
@@ -604,7 +643,14 @@ class ReportDetail extends Component {
|
|
|
</Picker>
|
|
|
</View>
|
|
|
<View className='home-item' style={{ marginTop: 30, paddingBottom: 30 }}>
|
|
|
- <Button type='primary' onClick={this.onSubsmit}>保存</Button>
|
|
|
+ <Button type='primary' onClick={this.onSubmit}>保存</Button>
|
|
|
+ <Button style={{ background: "#0079c2", color: "#fff" }}
|
|
|
+ onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ template: true
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >另存为模板</Button>
|
|
|
</View>
|
|
|
{/* 新增项 */}
|
|
|
{visible != "" &&
|
|
@@ -704,6 +750,40 @@ class ReportDetail extends Component {
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>}
|
|
|
+ {/* 另存为模板 */}
|
|
|
+ {this.state.template &&
|
|
|
+ <View className='mask'>
|
|
|
+ <View className='count'>
|
|
|
+ <View className='title'>另存为模板</View>
|
|
|
+ <View className='count_top' style={{ margin: "20px 0" }}>
|
|
|
+ <Input
|
|
|
+ value={this.state.name}
|
|
|
+ className='count_top_input'
|
|
|
+ placeholder='模板名称'
|
|
|
+ onChange={e => { this.setState({ name: e.detail.value }) }}
|
|
|
+ />
|
|
|
+ <Input
|
|
|
+ value={this.state.tags.toString().replace(/,/g, ",")}
|
|
|
+ style={{ marginTop: 15 }}
|
|
|
+ className='count_top_input'
|
|
|
+ placeholder='模板标签,输入逗号分割'
|
|
|
+ onChange={e => {
|
|
|
+ let val = e.detail.value.replace(/[\uff0c]/g, ",")
|
|
|
+ this.setState({
|
|
|
+ tags: !val ? [] : val.split(",")
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View className='count_foot'>
|
|
|
+ <Button onClick={this.onTemCancel}>取消</Button>
|
|
|
+ <Button style={{ marginTop: 0 }}
|
|
|
+ onClick={this.onReportTemplate}
|
|
|
+ >确认</Button>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
</View >
|
|
|
)
|
|
|
}
|