feat: adjust add task
This commit is contained in:
@@ -92,6 +92,15 @@ func GetWayByID(id string) (SendWays, error) {
|
|||||||
return way, nil
|
return way, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetWayByName(name string) (SendWays, error) {
|
||||||
|
var way SendWays
|
||||||
|
err := db.Where("name = ? ", name).Find(&way).Error
|
||||||
|
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return way, err
|
||||||
|
}
|
||||||
|
return way, nil
|
||||||
|
}
|
||||||
|
|
||||||
func DeleteMsgWay(id string) error {
|
func DeleteMsgWay(id string) error {
|
||||||
if err := db.Where("id = ?", id).Delete(&SendWays{}).Error; err != nil {
|
if err := db.Where("id = ?", id).Delete(&SendWays{}).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func AddMsgSendWay(c *gin.Context) {
|
|||||||
|
|
||||||
err := sendWayService.Add()
|
err := sendWayService.Add()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
appG.CResponse(http.StatusBadRequest, "添加渠道失败!", nil)
|
appG.CResponse(http.StatusBadRequest, fmt.Sprintf("添加渠道失败!原因:%s", err), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ func (sw *SendWay) GetByID() (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sw *SendWay) Add() error {
|
func (sw *SendWay) Add() error {
|
||||||
|
way, err := models.GetWayByName(sw.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(way.ID) > 0 {
|
||||||
|
return errors.New(fmt.Sprintf("已经存在同名的渠道名:%s", way.Name))
|
||||||
|
}
|
||||||
return models.AddSendWay(sw.Name, sw.Auth, sw.Type, sw.CreatedBy, sw.ModifiedBy)
|
return models.AddSendWay(sw.Name, sw.Auth, sw.Type, sw.CreatedBy, sw.ModifiedBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,8 @@
|
|||||||
<div class="ins-area">
|
<div class="ins-area">
|
||||||
|
|
||||||
<div class="ins-add">
|
<div class="ins-add">
|
||||||
<el-input v-model="searchWayID" placeholder="请输入要添加的渠道id" size="small" @change="searchID"
|
<el-autocomplete v-model="currSearchInputText" size="small" :fetch-suggestions="querySearchWayAsync"
|
||||||
class="searchInput"></el-input>
|
placeholder="请输入渠道名进行搜索" @select="handleSearchSelect" />
|
||||||
<el-button @click="searchID()" size="small" type="primary" style="margin-left: 20px;">查询</el-button>
|
|
||||||
|
|
||||||
<div class="store-area" v-if="isShowAddBox">
|
<div class="store-area" v-if="isShowAddBox">
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-input v-model="currInsInput[item.col]"
|
<el-input v-model="currInsInput[item.col]"
|
||||||
v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsInputs" :placeholder="item.desc" size="small"
|
v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsInputs" :placeholder="item.desc" size="small"
|
||||||
style="width: 200px; margin: 10px 40px 5px 0;" class="searchInput">
|
style="width: 200px; margin: 10px 40px 5px 0;">
|
||||||
</el-input>
|
</el-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -114,6 +113,8 @@ export default defineComponent({
|
|||||||
const pageState = usePageState();
|
const pageState = usePageState();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
insTableData: [],
|
insTableData: [],
|
||||||
|
currSearchWaysData: [],
|
||||||
|
currSearchInputText: '',
|
||||||
isShow: false,
|
isShow: false,
|
||||||
isShowAddBox: false,
|
isShowAddBox: false,
|
||||||
searchWayID: '',
|
searchWayID: '',
|
||||||
@@ -173,19 +174,40 @@ export default defineComponent({
|
|||||||
state.insTableData.push(insData);
|
state.insTableData.push(insData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchID = async () => {
|
// 匹配出当前搜索的渠道数据
|
||||||
const rsp = await request.get('/sendways/get', { params: { id: state.searchWayID } });
|
const matchSearchData = (way_name) => {
|
||||||
let data = await rsp.data;
|
let result = {};
|
||||||
state.isShowAddBox = Boolean(data.data);
|
state.currSearchWaysData.forEach(element => {
|
||||||
if (data.data) {
|
if (element.name == way_name) {
|
||||||
state.currWayTmp = data.data;
|
result = element;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSearchSelect = async () => {
|
||||||
|
let currWay = matchSearchData(state.currSearchInputText)
|
||||||
|
state.isShowAddBox = Boolean(currWay);
|
||||||
|
if (currWay) {
|
||||||
|
state.currWayTmp = currWay;
|
||||||
// 初始化currInsInput
|
// 初始化currInsInput
|
||||||
CONSTANT.WAYS_DATA_MAP[data.data.type].taskInsInputs.forEach(element => {
|
CONSTANT.WAYS_DATA_MAP[currWay.type].taskInsInputs.forEach(element => {
|
||||||
state.currInsInput[element.col] = ""
|
state.currInsInput[element.col] = ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const querySearchWayAsync = async (query, cb) => {
|
||||||
|
let params = { name: query };
|
||||||
|
const rsp = await request.get('/sendways/list', { params: params });
|
||||||
|
let tableData = await rsp.data.data.lists;
|
||||||
|
tableData.forEach(element => {
|
||||||
|
element.value = element.name
|
||||||
|
});
|
||||||
|
cb(tableData);
|
||||||
|
state.currSearchWaysData = tableData;
|
||||||
|
}
|
||||||
|
|
||||||
const getFinalData = () => {
|
const getFinalData = () => {
|
||||||
let postData = { id: state.currTaskInput.taskId, name: state.currTaskInput.taskName }
|
let postData = { id: state.currTaskInput.taskId, name: state.currTaskInput.taskName }
|
||||||
postData.ins_data = state.insTableData
|
postData.ins_data = state.insTableData
|
||||||
@@ -201,13 +223,9 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const formatExtraInfo = (scope) => {
|
|
||||||
// return CommonUtils.formatInsConfigDisplay(scope);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state), handleCancer, handleSubmit,
|
...toRefs(state), handleCancer, handleSubmit, querySearchWayAsync,
|
||||||
searchID, CONSTANT, CommonUtils,
|
handleSearchSelect, CONSTANT, CommonUtils,
|
||||||
clickStore, insRowStyle
|
clickStore, insRowStyle
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -241,16 +259,12 @@ export default defineComponent({
|
|||||||
flex: 55%;
|
flex: 55%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchInput {
|
:deep(.el-autocomplete) {
|
||||||
max-width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wayTitleInput {
|
|
||||||
max-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.taskNameInput {
|
.taskNameInput {
|
||||||
/* width: 80%; */
|
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user