1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import Taro, { Component } from '@tarojs/taro'
- import { View, Text, Button } from '@tarojs/components'
- import './templatelist.scss'
- export default class TemplateList extends Component {
- constructor(props) {
- super(props)
- this.state = {
- visible: false,
- selected: {},
- }
- }
- toggleVisible = () => {
- this.setState({
- visible: !this.state.visible,
- selected: {}
- })
- }
- // 确认删除
- delChap = () => {
- this.props.deleteTemplate(this.state.selected)
- this.setState({
- visible: false
- })
- }
- render() {
- const { list = [] } = this.props
- const popupStyle = { transform: `translateY(${Taro.pxTransform(-100)})` }
- return (
- <View className='list'>
- {
- list.length == 0
- ? <View>暂无</View>
- : list.map(item =>
- <View className='list__item' key={item.id}
- onClick={() => {
- Taro.navigateTo({
- url: "/pages/user/templatedetail?id=" + item.id
- })
- }}
- >
- <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_d'
- onClick={e => {
- e.stopPropagation()
- this.setState({
- visible: true,
- selected: item
- })
- }}
- >删除</View>
- </View>
- </View>
- </View>
- )
- }
- {/* 二级确认 */}
- {this.state.visible &&
- <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>
- )
- }
- }
|