优化
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { API } from './../../../utils/network/api'
|
||||
import Toast from 'tdesign-miniprogram/toast/index';
|
||||
const api = new API()
|
||||
const app = getApp()
|
||||
Page({
|
||||
|
||||
data: {
|
||||
navbarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
showCapsule: 2, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: '常用语', //导航栏 中间的标题
|
||||
},
|
||||
height: app.globalData.height,
|
||||
@@ -18,7 +19,17 @@ Page({
|
||||
show: false,
|
||||
add_message: "",
|
||||
current_words_type: 1,
|
||||
focus: true
|
||||
focus: true,
|
||||
words_css: "border-radius: 20rpx;margin-bottom: 20rpx;",
|
||||
from: ""
|
||||
},
|
||||
onLoad(options){
|
||||
let from = options.from;
|
||||
if(from) {
|
||||
this.setData({
|
||||
from: from
|
||||
})
|
||||
}
|
||||
},
|
||||
onTabChange(e){
|
||||
this.setData({
|
||||
@@ -45,17 +56,33 @@ Page({
|
||||
|
||||
api.postDoctorWords({words_type: words_type, words: words}).then(response => {
|
||||
console.log(response);
|
||||
let list_name = "list_" + words_type;
|
||||
let list = this.data[list_name];
|
||||
let obj = {};
|
||||
obj.words = words;
|
||||
list.push(obj);
|
||||
console.log(list_name);
|
||||
this.setData({
|
||||
[list_name]: list,
|
||||
add_message: "",
|
||||
show: false
|
||||
})
|
||||
}).then(()=>{
|
||||
this.getList(words_type)
|
||||
}).catch(errors => {console.error(errors);})
|
||||
},
|
||||
delWords(e){
|
||||
console.log(e);
|
||||
let words_type = this.data.current_words_type;
|
||||
let doctor_words_id = e.currentTarget.dataset.doctor_words_id;
|
||||
if(doctor_words_id == ""){
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
message: '系统常用语,无法删除',
|
||||
theme: 'warning',
|
||||
direction: 'column',
|
||||
});
|
||||
return
|
||||
}
|
||||
api.delDoctorWords({doctor_words_id: doctor_words_id}).then(response => {
|
||||
console.log(response);
|
||||
|
||||
}).then(()=>{
|
||||
this.getList(words_type)
|
||||
}).catch(errors => {console.error(errors);})
|
||||
},
|
||||
showAdd(){
|
||||
@@ -63,7 +90,6 @@ Page({
|
||||
show: true,
|
||||
});
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.setData({
|
||||
show: false,
|
||||
@@ -73,5 +99,38 @@ Page({
|
||||
this.setData({
|
||||
focus: true
|
||||
})
|
||||
},
|
||||
wordsClose(e){
|
||||
console.log(e);
|
||||
const { position, instance } = e.detail;
|
||||
console.log(position)
|
||||
console.log(instance)
|
||||
switch (position) {
|
||||
case 'left':
|
||||
case 'cell':
|
||||
instance.close();
|
||||
break;
|
||||
case 'right':
|
||||
Dialog.confirm({
|
||||
message: '确定删除吗?',
|
||||
}).then(() => {
|
||||
instance.close();
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
wordsOpen(e){
|
||||
console.log("open")
|
||||
console.log(e);
|
||||
},
|
||||
wordsClick(e){
|
||||
console.log("click")
|
||||
console.log(e);
|
||||
let words = e.currentTarget.dataset.words;
|
||||
let from = this.data.from;
|
||||
if(from){
|
||||
wx.setStorageSync('words', words);
|
||||
wx.navigateBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -7,6 +7,8 @@
|
||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-swipe-cell": "@vant/weapp/swipe-cell/index",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast"
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<t-tabs
|
||||
defaultValue="{{ current_words_type }}"
|
||||
sticky
|
||||
swipeable="{{false}}"
|
||||
stickyProps="{{stickyProps}}"
|
||||
t-class="custom-tabs"
|
||||
bind:change="onTabChange"
|
||||
@@ -12,18 +13,35 @@
|
||||
>
|
||||
<t-tab-panel label="问诊" value="1">
|
||||
<view class="item_list">
|
||||
<van-cell size="large" custom-style="border-radius: 20rpx;margin-bottom: 20rpx;" title="{{index + 1}}、{{item.words}}" wx:for="{{list_1}}" />
|
||||
<van-swipe-cell right-width="{{ 65 }}"
|
||||
bind:close="wordsClose"
|
||||
bind:open="wordsOpen"
|
||||
bind:click="wordsClick"
|
||||
data-words="{{item.words}}"
|
||||
wx:for="{{list_1}}">
|
||||
<van-cell-group>
|
||||
<van-cell custom-style="{{words_css}}" title="{{index + 1}}、{{item.words}}" />
|
||||
</van-cell-group>
|
||||
<view slot="right" class="delWords" bindtap="delWords" data-doctor_words_id="{{item.doctor_words_id}}">删除</view>
|
||||
</van-swipe-cell>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<van-button bind:click="showAdd" class="addbtn" custom-style="border-radius: 20rpx;margin: 0 auto;width: 92%;position: relative;top: 50%; transform: translateY(-50%);" type="primary" color="#3CC7C0" block>添加常用语</van-button>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
</t-tab-panel>
|
||||
<t-tab-panel label="处方" value="2">
|
||||
<view class="item_list">
|
||||
<van-cell size="large" custom-style="border-radius: 20rpx;margin-bottom: 20rpx;" title="{{index+1}}、{{item.words}}" wx:for="{{list_2}}" />
|
||||
<van-swipe-cell right-width="{{ 65 }}"
|
||||
bind:close="wordsClose"
|
||||
bind:open="wordsOpen"
|
||||
bind:click="wordsClick"
|
||||
data-words="{{item.words}}"
|
||||
wx:for="{{list_2}}">
|
||||
<van-cell-group>
|
||||
<van-cell custom-style="{{words_css}}" title="{{index + 1}}、{{item.words}}" />
|
||||
</van-cell-group>
|
||||
<view slot="right" class="delWords" bindtap="delWords" data-doctor_words_id="{{item.doctor_words_id}}">删除</view>
|
||||
</van-swipe-cell>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<van-button bind:click="showAdd" class="addbtn" custom-style="border-radius: 20rpx;margin: 0 auto;width: 92%;position: relative;top: 50%; transform: translateY(-50%);" type="primary" color="#3CC7C0" block>添加常用语</van-button>
|
||||
@@ -59,4 +77,5 @@
|
||||
<van-cell url="/Pages/yishi/quickreply_data/index?title=快速问诊快捷回复" custom-style="border-radius: 20rpx;margin-bottom: 20rpx;" title="2、设置处方的快捷回复" is-link />
|
||||
<van-cell url="/Pages/yishi/quickreply_data/index?title=义诊快捷回复" custom-style="border-radius: 20rpx;margin-bottom: 20rpx;" title="3、设置处方的快捷回复" is-link />
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<t-toast id="t-toast" />
|
||||
@@ -55,4 +55,13 @@ page{
|
||||
}
|
||||
.popup_box_content{
|
||||
flex: 5;
|
||||
}
|
||||
.delWords{
|
||||
background-color: red;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 65px;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
}
|
||||
Reference in New Issue
Block a user