新增模型等

dev_2022-03-03
yujialong 3 years ago
parent ddcf41931f
commit 2cf0f0674c
  1. 21
      package-lock.json
  2. 1
      package.json
  3. BIN
      src/assets/img/error.png
  4. 402
      src/components/codemirror.vue
  5. 5
      src/router/index.js
  6. 55
      src/views/serve/addModel.vue
  7. 2
      src/views/serve/backstage/modelType.vue
  8. 476
      src/views/serve/backstage/sourceModel.vue
  9. 23
      src/views/serve/backstage/sourceType.vue

21
package-lock.json generated

@ -1049,7 +1049,7 @@
},
"@types/uuid": {
"version": "8.3.3",
"resolved": "https://registry.npmmirror.com/@types/uuid/download/@types/uuid-8.3.3.tgz?cache=0&sync_timestamp=1637271089246&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40types%2Fuuid%2Fdownload%2F%40types%2Fuuid-8.3.3.tgz",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.3.tgz",
"integrity": "sha512-0LbEEx1zxrYB3pgpd1M5lEhLcXjKJnYghvhTRgaBeUivLHMDM1TzF3IJ6hXU2+8uA4Xz+5BA63mtZo5DjVT8iA=="
},
"@vue/babel-helper-vue-jsx-merge-props": {
@ -2803,6 +2803,11 @@
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"codemirror": {
"version": "5.65.2",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.2.tgz",
"integrity": "sha512-SZM4Zq7XEC8Fhroqe3LxbEEX1zUPWH1wMr5zxiBuiUF64iYOUH/JI88v4tBag8MiBS8B8gRv8O1pPXGYXQ4ErA=="
},
"collection-visit": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
@ -3862,6 +3867,11 @@
"integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==",
"dev": true
},
"diff-match-patch": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz",
"integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw=="
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
@ -12615,6 +12625,15 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.10.tgz",
"integrity": "sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ=="
},
"vue-codemirror": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/vue-codemirror/-/vue-codemirror-4.0.6.tgz",
"integrity": "sha512-ilU7Uf0mqBNSSV3KT7FNEeRIxH4s1fmpG4TfHlzvXn0QiQAbkXS9lLfwuZpaBVEnpP5CSE62iGJjoliTuA8poQ==",
"requires": {
"codemirror": "^5.41.0",
"diff-match-patch": "^1.0.0"
}
},
"vue-cropperjs": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/vue-cropperjs/-/vue-cropperjs-3.0.0.tgz",

@ -17,6 +17,7 @@
"px2rem-loader": "^0.1.9",
"sortablejs": "^1.14.0",
"vue": "^2.6.10",
"vue-codemirror": "^4.0.6",
"vue-cropperjs": "^3.0.0",
"vue-pdf": "^4.3.0",
"vue-quill-editor": "^3.0.6",

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

@ -0,0 +1,402 @@
<template>
<div class="wrap">
<div class="left">
<codemirror
v-model="codeVal"
:options="cmOption"
class="code-mirror"
@ready="ready"
ref="codemirror"
></codemirror>
<el-button
class="run btn"
type="primary"
@click="runCode"
>运行</el-button>
</div>
<div class="code-right answer">
<p class="text-wrapper">{{ runResult }}</p>
<div class="pic-wrap" v-if="picSrcList.length">
<div class="pic-item" v-for="(img, i) in picSrcList" :key="i">
<el-image
class="pic"
:src="img"
:preview-src-list="picSrcList">
</el-image>
<el-button class="download-btn btn" type="primary" size="mini" @click="downloadPic(i)">下载图片</el-button>
<a :ref="'picLink' + i" style="display: none;" download="运行结果.png" :href="img">下载图片</a>
</div>
</div>
<div class="result-right t-color" v-show="isError">
<!-- <img :src="require(`@/assets/images/system/${systemId}/yes.png`)" alt />运行成功 -->
</div>
<div class="result-wrong" v-show="isError === 0">
<img src="@/assets/img/error.png" alt />
{{errLine}}行出现错误
<el-button class="tips-btn" @click="getTips" v-show="showTips">提示</el-button>
<el-dialog title="答案提示" center :close-on-click-modal="false" :visible.sync="tipsVisible">
<el-tabs>
<el-tab-pane label="参考答案">
<div class="answer-wrap" v-html="answer"></div>
</el-tab-pane>
</el-tabs>
</el-dialog>
</div>
</div>
</div>
</template>
<script>
import { codemirror } from "vue-codemirror";
import "codemirror/theme/ambiance.css"; //
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/python/python.js";
import "codemirror/lib/codemirror.css";
// require active-line.js
import "codemirror/addon/selection/active-line.js";
// styleSelectedText
import "codemirror/addon/selection/mark-selection.js";
// hint
import "codemirror/addon/hint/show-hint.js";
import "codemirror/addon/hint/sql-hint.js";
import "codemirror/addon/hint/show-hint.css";
import "codemirror/addon/hint/javascript-hint.js";
// highlightSelectionMatches
import "codemirror/addon/scroll/annotatescrollbar.js";
import "codemirror/addon/search/matchesonscrollbar.js";
import "codemirror/addon/search/match-highlighter.js";
// keyMap
import "codemirror/mode/clike/clike.js";
import "codemirror/mode/sql/sql.js";
import "codemirror/addon/edit/matchbrackets.js";
import "codemirror/addon/comment/comment.js";
import "codemirror/addon/dialog/dialog.js";
import "codemirror/addon/dialog/dialog.css";
import "codemirror/addon/search/searchcursor.js";
import "codemirror/addon/search/search.js";
import "codemirror/keymap/sublime.js";
// foldGutter
import "codemirror/addon/fold/foldgutter.css";
import "codemirror/addon/fold/brace-fold.js";
import "codemirror/addon/fold/comment-fold.js";
import "codemirror/addon/fold/foldcode.js";
import "codemirror/addon/fold/foldgutter.js";
import "codemirror/addon/fold/indent-fold.js";
import "codemirror/addon/fold/markdown-fold.js";
import "codemirror/addon/fold/xml-fold.js";
//
import "codemirror/theme/monokai.css";
import "codemirror/theme/base16-light.css";
import { Loading } from 'element-ui';
export default {
props: ['code', 'codeId', 'projectId', 'retResult'],
data() {
return {
showTips: false, //
answer: '', //
codeVal: this.code,
runResult: '', //
isError: false, //
errLine: '', //
tipsVisible: false, //
picSrcList: [],
loadIns: null, // loading
cmOption: {
scrollbarStyle: "native",
tabSize: 2, // tab
styleActiveLine: true, //
lineNumbers: true, //
styleSelectedText: true,
line: true,
foldGutter: true, //
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, //
mode: 'python',
lineWrapping: true, //
autoCloseTags: true,//
autoCloseBrackets: true,//
// hint.js options
hintOptions: {
//
completeSingle: false
},
// sublimeemacsvim
keyMap: "sublime",
matchBrackets: true,
showCursorWhenSelecting: true,
theme: "monokai" //
}
};
},
components: {
codemirror
},
watch: {
codeVal(val) {
this.$emit("update:code", val)
}
},
mounted() {
},
methods: {
//
ready() {
const code = this.$refs.codemirror.codemirror
code.setSize("auto", "calc(100vh - 167px)");
code.on('keypress', function() {
//
code.showHint()
});
},
//
runCode() {
let code = this.codeVal
if (!code) {
this.$message({
message: "警告哦,内容为空不可运行",
type: "warning"
})
} else {
const bcId = this.judgmentId
const cid = this.courseId
const projectId = this.projectId
this.loadIns = Loading.service({
background: 'transparent'
})
// savefig(python),savefig
code = code.replace(/\.savefig\(([\u4e00-\u9fa5\w]*?['"])/mg, str => {
return str + Date.now()
})
// Python
this.$post(this.api.runPythonCode, {
code,
bcId,
cid,
projectId
}).then(res => {
const data = res.code
const photo = data.photoUrl
const result = data.runResult
this.$emit('cache') //
this.loadIns.close()
this.picSrcList = []
if (photo) this.picSrcList = photo.split(',')
this.$emit('update:codeId', res.codeId) // coddeId
this.$emit('update:answer', result) //
this.$emit('update:retResult', data.retResult) //
let imgList = ''
let firtImg = ''
try {
imgList = eval(result)
} catch (error) {}
if (imgList && imgList.length) firtImg = imgList[0]
//
if (photo) {
this.isError = '' //
const text = result.replace(photo, '') //
this.runResult = text
this.picSrcList = photo.split(',')
} else if (imgList instanceof Array && imgList.length && typeof firtImg === 'string' && (firtImg.includes('.jpg') || firtImg.includes('.png') || firtImg.includes('img'))) {
/**
* 这段是为要下载图片的项目案例写的后端会返回图片名称的数组前端负责循环这个数组然后下载下来
* 只有该系统有这段代码因为其他7个系统没有下载图片的项目后续如果加了直接把这段代码复制过去即可
*/
imgList.map((n,i) => {
// util.downloadFile(`${i+1}.jpg`,n)
})
this.isError = 0
this.runResult = '下载完成'
} else {
this.isError = data.retResult
this.runResult = result
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length))
}
}).catch(res => {
res.status == 500 && this.$message.error('检测到代码里有非法代码,请检查是否有调用系统命令。')
this.loadIns.close()
})
}
},
//
downloadPic(i) {
this.$refs['picLink' + i][0].click()
},
//
getTips() {
this.tipsVisible = true
this.$get(this.api.queryBcJudgmentByBcId, {
bcId: this.judgmentId
}).then(res => {
this.answer = res.experimentCode
}).catch(err => {})
}
}
};
</script>
<style lang="scss" scoped>
.wrap {
display: flex;
}
.left{
position: relative;
width: calc(100% - 400px);
}
.text-wrapper {
white-space: pre-wrap;
}
/deep/.answer {
.el-tab-pane {
padding: 0 10px;
height: 340px;
overflow: hidden;
overflow-y: auto;
white-space: pre-wrap;
}
.el-dialog--center {
width: 500px;
height: 500px;
}
.el-dialog__title {
font-size: 22px;
font-weight: 500;
}
.el-tabs__nav-wrap::after {
background-color: #333;
}
.el-tabs__active-bar {
height: 0;
background-color: #fff;
}
.el-tabs__header {
background-color: #333;
}
.el-dialog--center .el-dialog__body {
padding: 0;
}
.el-tabs__item {
width: 80px;
color: #fff;
}
.el-tabs--top .el-tabs__item.is-top:nth-child(2) {
padding-left: 20px;
}
.el-tabs__item.is-active {
color: #fff !important;
background-color: #333 !important;
}
.tips-btn {
margin-top: 10px;
height: 40px;
width: 90px;
border: none;
position: absolute;
right: 0;
background: rgba(255, 49, 49, 1);
color: rgba(255, 255, 255, 1);
&:hover,
&:focus,
&:active {
background: rgba(255, 49, 49, 1);
color: rgba(255, 255, 255, 1);
}
}
}
/deep/.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
height: 30px;
line-height: 30px;
}
.result-right {
background-color: rgba(43, 40, 22, 1);
}
.result-wrong {
background-color: rgba(43, 22, 22, 1);
color: #f00;
}
.result-wrong,
.result-right {
position: absolute;
left: 20px;
right: 20px;
display: flex;
bottom: 10px;
padding: 0 10px;
img {
width: 40px;
height: 40px;
margin-top: 5px;
margin-right: 10px;
}
}
.code-right {
width: 500px;
color: #fff;
background: #1b1b1b;
display: inline-block;
position: relative;
overflow-x: auto;
p {
font-size: 18px;
margin: 10px;
position: absolute;
width: calc(100% - 14px);
height: calc(100vh - 247px);
overflow: auto;
}
}
.pic-wrap {
position: absolute;
left: 0;
right: 0;
bottom: 5px;
display: flex;
max-width: calc(100% - 50px);
margin: 0 auto;
text-align: center;
overflow: auto;
.pic-item {
margin: 0 5px 5px;
&:only-child {
.pic {
width: 80%;
}
}
}
.pic {
display: block;
width: 100px;
margin: 0 auto 10px;
}
}
.code-mask{
z-index: 2;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.run{
z-index:99;
position:absolute;
right: 50px;
bottom:15px;
width:100px;
color:#fff;
}
.download-btn{
color:#fff;
}
/deep/.answer-wrap{
pre{
width: 100%;
white-space: pre-wrap;
}
img{
max-width: 100%;
}
}
</style>

@ -62,6 +62,11 @@ let router = new Router({
component: () => import( '../views/serve/backstage'),
// meta: { title: '服务配置' }
},
{
path: '/addModel',
component: () => import( '../views/serve/addModel'),
// meta: { title: '服务配置' }
},
{
path: '/addconfigure',
component: () => import( '../views/serve/AddConfigure.vue'),

@ -0,0 +1,55 @@
<template>
<div class="wrap">
<el-card shadow="hover" class="mgb20">
<div class="flex-between">
<div class="per_title" v-preventReClick @click="$router.back()">
<i class="el-icon-arrow-left"></i>
<span class="per_back">返回</span>
<span class="per_school" v-text="isDetail ? '查看源模型' : (customerId ? '编辑源模型' : '新增源模型')"></span>
</div>
<el-button v-if="!isDetail" type="primary" round v-preventReClick @click="submit">确定</el-button>
</div>
</el-card>
<el-card shadow="hover">
<el-form ref="form" label-width="120px" :disabled="isDetail">
<el-form-item label="模型名称">
<el-input placeholder="请输入模型名称" v-model="form.position" maxlength="25"></el-input>
</el-form-item>
<el-form-item label="模型代码">
<codemirror
></codemirror>
</el-form-item>
</el-form>
</el-card>
</div>
</template>
<script>
import codemirror from '@/components/codemirror'
export default {
components:{ codemirror },
data() {
return {
customerId : this.$route.query.id,
isDetail : Boolean(this.$route.query.show),
form: {
}
};
},
mounted() {
},
methods: {
//
submit(){
},
}
};
</script>
<style lang="scss" scoped>
</style>

@ -2,7 +2,7 @@
<div>
<div>
<div class="flex-between m-b-20">
<div>同步原始模型列表</div>
<el-button type="text" icon="el-icon-refresh">同步原始模型列表</el-button>
<el-button type="text" @click="addMajor">添加</el-button>
</div>
<org-tree

@ -13,10 +13,10 @@
</li>
</ul>
<div>
<el-button type="primary" round @click="addTeacher">新增</el-button>
<el-button type="primary" round @click="delAllSelection">批量删除</el-button>
<el-button type="primary" round @click="delAllSelection">批量禁用</el-button>
<el-button type="primary" round @click="delAllSelection">批量开启</el-button>
<el-button type="primary" round @click="add">新增</el-button>
<el-button type="primary" round @click="batchDel">批量删除</el-button>
<el-button type="primary" round @click="batchOff">批量禁用</el-button>
<el-button type="primary" round @click="batchOpen">批量开启</el-button>
</div>
</div>
@ -29,9 +29,9 @@
<el-table-column prop="workNumber" label="状态" align="center"></el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button type="text" @click="showTeacher(scope.row)">查看</el-button>
<el-button type="text" @click="delTeacher(scope.row)">编辑</el-button>
<el-button type="text" @click="delTeacher(scope.row)">删除</el-button>
<el-button type="text" @click="show(scope.row)">查看</el-button>
<el-button type="text" @click="edit(scope.row)">编辑</el-button>
<el-button type="text" @click="del(scope.row)">删除</el-button>
<el-switch v-model="scope.row.isEnable" :active-value="1" :inactive-value="0" style="margin: 0 10px 0 5px" :active-text="scope.row.isEnable ? '启用' : '禁用'" @change="switchOff($event,scope.row,scope.$index)"></el-switch>
</template>
</el-table-column>
@ -40,82 +40,6 @@
<el-pagination background layout="total, prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination>
</div>
</div>
<el-dialog :title="isDetail ? '查看员工' : (isAdd ? '新增员工' : '编辑员工')" :visible.sync="teacherVisible"
width="30%" @close="closeTeacher" class="dialog" :close-on-click-modal="false">
<el-form ref="teacherForm" :model="teacherForm" :rules="rules" label-width="150px" :disabled="isDetail" style='margin-right: 80px;'>
<el-form-item prop="account" label="账号">
<el-input v-model.trim="teacherForm.account" placeholder="请输入职工账号"></el-input>
</el-form-item>
<el-form-item prop="userName" label="用户姓名">
<el-input v-model.trim="teacherForm.userName" placeholder="请输入员工姓名"></el-input>
</el-form-item>
<el-form-item prop="roleValue" label="账号角色">
<el-select v-model="teacherForm.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple style="width: 100%;height: 32px">
<el-option
v-for="item in roleList"
:key="item.id"
:label="item.roleName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="uniqueIdentification" label="唯一标识">
<el-input disabled v-model.trim="teacherForm.uniqueIdentification" placeholder="请输入职工工号获取唯一标识"></el-input>
</el-form-item>
<el-form-item prop="workNumber" label="工号">
<el-input v-model.trim="teacherForm.workNumber" placeholder="请输入职工工号"></el-input>
</el-form-item>
<el-form-item v-for="item in teacherForm.roleAndDeptList" :label="`${item.roleName}所属部门`" :rules="{
required: true, message: '请选择', trigger: 'change'
}">
<el-cascader
v-model="item.cascaderValue"
:options="orgList"
:props="casProps"
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input v-model.trim="teacherForm.phone" placeholder="请输入手机号" maxlength="11" @blur="phoneChange"></el-input>
</el-form-item>
<el-form-item prop="email" label="邮箱">
<el-input v-model.trim="teacherForm.email" placeholder="请输入邮箱" @blur="emailChange"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button @click="closeTeacher"> </el-button>
<el-button type="primary" @click="saveSure('teacherForm')"> </el-button>
</span>
</el-dialog>
<el-dialog title="批量导入" :visible.sync="importVisible" width="24%" :close-on-click-modal="false">
<div style="text-align: center">
<div style="margin-bottom: 10px;">
<el-button type="primary" @click="downLoad">模板下载<i class="el-icon-download el-icon--right"></i></el-button>
</div>
<el-upload
name="file"
accept=".xls,.xlsx"
:on-remove="handleRemove"
:on-error="uploadError"
:on-success="uploadSuccess"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:action="this.api.importStaff"
:file-list="uploadList"
:headers="headers"
>
<el-button type="primary" class="ml20">上传文件<i class="el-icon-upload2 el-icon--right"></i></el-button>
</el-upload>
<el-link v-if="uploadFaild" type="primary" @click="showFaild">部分数据导入失败查看失败原因</el-link>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="importVisible = false"> </el-button>
<el-button type="primary" @click="uploadSure"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
@ -123,32 +47,6 @@ import Setting from "@/setting";
import org from "./sourceType"
export default {
data() {
var accountPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入账号'));
} else {
var pattern = /^[A-Za-z0-9]*$/;
if(pattern.test(value)){
this.accountChange();
callback();
}else{
callback(new Error('请输入正确账号格式'));
}
}
};
var workNumberPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入职工工号'));
} else {
var pattern = /^[a-zA-Z0-9]*$/;
if(pattern.test(value)){
this.workNumberChange();
callback();
}else{
callback(new Error('职工工号必须为数字或英文'));
}
}
};
return {
exportCode: "",
headers: {
@ -173,35 +71,6 @@ export default {
phone: "",
email: ""
},
rules: {
account: [
{ required: true, validator: accountPass, trigger: 'blur' }
],
userName: [
{ required: true, message: "请输入用户姓名", trigger: "blur" }
],
roleValue: [
{ required: true, message: "请选择账号角色", trigger: "change" }
],
workNumber: [
{ required: true, validator: workNumberPass , trigger: 'blur' }
],
uniqueIdentification: [
// { required: true, message: '', trigger: 'blur' },
],
phone: [
// { required: true, message: '', trigger: 'blur' },
{ pattern: /^1[3456789]\d{9}$/, message: "请输入正确的手机号", trigger: "blur"}
],
email: [
// { required: true, message: '', trigger: 'blur' },
{
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
message: "请输入正确的邮箱",
trigger: "blur"
}
],
},
accountReapeat: false,
workNumberReapeat: false,
phoneRepeat: false,
@ -235,8 +104,7 @@ export default {
}
},
mounted() {
// this.getRoleData()
// this.getData()
},
methods: {
getSingle(data) {
@ -300,208 +168,82 @@ export default {
this.$refs.teacherForm.clearValidate();
this.teacherVisible = false;
},
addTeacher() { //
this.isDetail = false;
this.isAdd = true;
this.teacherVisible = true;
this.orgList = this.$refs.org.orgList;
},
getStaffDetail(accountId) { //
this.$get(`${this.api.staffDetail}?accountId=${accountId}`).then(res => {
let { data } = res;
this.teacherForm = data;
this.teacherForm.roleValue = data.roleAndDeptList.map(i => i.roleId);
this.teacherForm.roleAndDeptList = data.roleAndDeptList.map(i => {
i.cascaderValue = [i.staffArchitectureId, i.gradeId]
return i;
});
console.log(22, this.teacherForm)
}).catch(res => {});
},
resetPassword(row) { //
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=111aaa`).then(res => {
this.$message.success("重置成功");
}).catch(res => {
});
}).catch(() => {
});
},
editTeacher(row) { //
this.isDetail = false;
this.isAdd = false;
this.teacherVisible = true;
this.orgList = this.$refs.org.orgList;
this.getStaffDetail(row.accountId);
},
showTeacher(row) { //
this.isDetail = true;
this.isAdd = false;
this.teacherVisible = true;
this.orgList = this.$refs.org.orgList;
this.getStaffDetail(row.accountId);
},
accountChange() { //
if (this.teacherForm.account) {
let url = "";
if (this.isAdd) {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&account=${this.teacherForm.account}&workNumber=`;
} else {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.teacherForm.accountId}&account=${this.teacherForm.account}&workNumber=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.accountReapeat = false;
}
}).catch( err => {
this.accountReapeat = true;
});
}
},
workNumberChange() { //
if (this.teacherForm.workNumber) {
let url = "";
if (this.isAdd) {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&workNumber=${this.teacherForm.workNumber}&account=`;
} else {
url = `${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}&accountId=${this.teacherForm.accountId}&workNumber=${this.teacherForm.workNumber}&account=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.workNumberReapeat = false;
}
}).catch( err => {
this.workNumberReapeat = true;
});
}
//
add() {
this.$router.push('/addModel')
},
phoneChange() { //
let regex = /^1[3456789]\d{9}$/;
if (regex.test(this.teacherForm.phone)) {
let url = "";
if (this.isAdd) {
url = `${this.api.checkEmailOrPhone}?phone=${this.teacherForm.phone}&email=`;
} else {
url = `${this.api.checkEmailOrPhone}?accountId=${this.teacherForm.accountId}&phone=${this.teacherForm.phone}&email=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.phoneRepeat = false;
}
}).catch( err => {
this.phoneRepeat = true;
//
batchDel() {
if (this.multipleSelection.length) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
let ids = this.multipleSelection.map(item => {
return item.accountId;
});
this.$post(`${this.api.delStaff}?accountIds=${ids.toString()}`).then(res => {
this.$refs.table.clearSelection();
this.$message.success("删除成功");
this.getData();
}).catch(res => {})
}).catch(() => {
});
} else {
this.$message.error("请先选择模型 !")
}
},
emailChange() { //
let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
if (regex.test(this.teacherForm.email)) {
let url = "";
if (this.isAdd) {
url = `${this.api.checkEmailOrPhone}?email=${this.teacherForm.email}&phone=`;
} else {
url = `${this.api.checkEmailOrPhone}?accountId=${this.teacherForm.accountId}&email=${this.teacherForm.email}&phone=`;
}
this.$post(url).then(res => {
if (res.status === 200) {
this.emailRepeat = false;
}
}).catch( err => {
this.emailRepeat = true;
//
batchOff() {
if (this.multipleSelection.length) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
let ids = this.multipleSelection.map(item => {
return item.accountId;
});
this.$post(`${this.api.delStaff}?accountIds=${ids.toString()}`).then(res => {
this.$refs.table.clearSelection();
this.$message.success("删除成功");
this.getData();
}).catch(res => {})
}).catch(() => {
});
} else {
this.$message.error("请先选择模型 !")
}
},
roleChange(value) { //
console.log(this.teacherForm.roleValue)
if (value.length) {
let ids = this.teacherForm.roleAndDeptList.map(e => e.roleId);
this.roleList.forEach(i => {
let obj = {
roleId: "",
roleName: "",
cascaderValue: []
};
if (value.includes(i.id) && !ids.includes(i.id)) {
console.log(i)
obj.roleId = i.id;
obj.roleName = i.roleName;
this.teacherForm.roleAndDeptList.push(obj);
}
//
batchOpen() {
if (this.multipleSelection.length) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
let ids = this.multipleSelection.map(item => {
return item.accountId;
});
this.$post(`${this.api.delStaff}?accountIds=${ids.toString()}`).then(res => {
this.$refs.table.clearSelection();
this.$message.success("删除成功");
this.getData();
}).catch(res => {})
}).catch(() => {
});
} else {
this.teacherForm.roleAndDeptList.splice(0);
this.$message.error("请先选择模型 !")
}
},
roleRemove(value) { //
let list = [];
for(var i=0;i<this.teacherForm.roleAndDeptList.length;i++){
if (this.teacherForm.roleAndDeptList[i].roleId == value){
}else{
list.push(this.teacherForm.roleAndDeptList[i])
}
}
this.teacherForm.roleAndDeptList = list
//
show(row) {
this.$router.push('/addModel')
},
async saveSure(teacherForm) {
this.$refs[teacherForm].validate((valid) => {
if (valid) {
if (this.submiting) return false
if (this.accountReapeat) return this.$message.warning("该账号已存在");
if (this.workNumberReapeat) return this.$message.warning("该员工工号已存在");
if (this.phoneRepeat) return this.$message.warning("该手机号已存在");
if (this.emailRepeat) return this.$message.warning("该邮箱已存在");
let data = {
accountId: this.teacherForm.accountId,
account: this.teacherForm.account,
userName: this.teacherForm.userName,
roleAndDeptList: [],
uniqueIdentification: this.teacherForm.uniqueIdentification ? this.teacherForm.uniqueIdentification : new Date().getTime(),
workNumber: this.teacherForm.workNumber,
phone: this.teacherForm.phone,
email: this.teacherForm.email
};
if (this.teacherForm.roleAndDeptList.length){
for (let i = 0; i < this.teacherForm.roleAndDeptList.length; i++) {
if (this.teacherForm.roleAndDeptList[i].cascaderValue.length < 2) {
this.$message.warning(`请选择${this.teacherForm.roleAndDeptList[i].roleName}所属部门`)
return;
} else {
let obj = {
roleId: this.teacherForm.roleAndDeptList[i].roleId,
staffArchitectureId: this.teacherForm.roleAndDeptList[i].cascaderValue[0],
gradeId: this.teacherForm.roleAndDeptList[i].cascaderValue[1]
};
data.roleAndDeptList.push(obj);
}
}
}
this.submiting = true
if (this.teacherForm.accountId) {
this.$post(this.api.modifyStaff, data).then(res => {
this.$message.success("编辑成功");
this.closeTeacher();
this.getData();
this.submiting = false
}).catch(res => {
this.submiting = false
});
} else {
this.$post(this.api.saveStaff, data).then(res => {
this.$message.success("添加成功");
this.closeTeacher();
this.getData();
this.submiting = false
}).catch(res => {
this.submiting = false
});
}
} else {
return false;
}
});
//
edit(row) {
this.$router.push('/addModel')
},
delTeacher(row) {
del(row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
@ -526,85 +268,9 @@ export default {
handleSelectionChange(val) {
this.multipleSelection = val;
},
delAllSelection() {
if (this.multipleSelection.length) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
let ids = this.multipleSelection.map(item => {
return item.accountId;
});
this.$post(`${this.api.delStaff}?accountIds=${ids.toString()}`).then(res => {
this.multipleSelection = [];
this.$refs.table.clearSelection();
this.$message.success("删除成功");
this.getData();
}).catch(res => {
});
}).catch(() => {
});
} else {
this.$message.error("请先选择员工 !");
}
},
batchImport() {
this.importVisible = true;
this.uploadList = [];
this.uploadFaild = false;
},
searchTeacher() {
this.page = 1;
this.getData();
},
handleCurrentChange(val) {
this.page = val;
this.getData();
},
downLoad() {
location.href = this.api.staffTemplate;
},
showFaild() {
location.href = `${this.api.exportFailureStaff}?exportCode=${this.exportCode}`;
},
//
handleExceed(files, fileList) {
this.$message.warning(
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
);
},
uploadSuccess(res, file, fileList) {
console.log(res);
this.uploadFaild = false;
if (res.status === 200) {
if (res.data.exportCode) {
this.exportCode = res.data.exportCode;
this.uploadFaild = true;
}
this.$message.success(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`);
} else {
res.message ? this.$message.error(res.message) : this.$message.error("上传失败,请检查数据");
}
},
uploadError(err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
});
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleRemove(file, fileList) {
this.uploadList = fileList;
this.uploadFaild = false;
},
uploadSure() {
this.importVisible = false;
this.page = 1;
this.keyword = "";
this.getData();
}
}
};

@ -61,7 +61,6 @@ export default {
systemId: this.$route.query.systemId,
orgList: [],
typeVisible: false,
depVisible: false,
Form: {
id: '',
parentId: '',
@ -87,14 +86,6 @@ export default {
this.orgList = res.data
}).catch(res => {})
},
closeDia() {
this.$refs.Form.resetFields()
this.Form = {
id: '',
parentId: '',
categoryName: ''
}
},
getSingle(data) {
this.$emit('getSingle', data)
},
@ -104,8 +95,8 @@ export default {
//
addType(node, data) {
this.typeVisible = true
this.Form.parentId = data.id || 0
this.Form.level = node ? node.level - 1 : 0
this.Form.parentId = data ? data.id : 0
this.Form.level = node ? node.level : 0
},
//
editType(data) {
@ -123,8 +114,8 @@ export default {
categoryName: form.categoryName,
systemId: this.systemId
}
debugger
if (data.id) {
debugger
this.$post(this.api.updateProfessional, data).then(res => {
his.$message.success("编辑成功")
this.typeVisible = false
@ -142,6 +133,14 @@ export default {
}
})
},
closeDia() {
this.$refs.Form.resetFields()
this.Form = {
id: '',
parentId: '',
categoryName: ''
}
},
//
delType(item) {
this.$confirm("确定要删除分类吗?", "提示", {

Loading…
Cancel
Save