|
@@ -245,7 +245,16 @@
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
- <el-input v-model="sItem.param2" clearable placeholder="请输入" style="width: 100%;" />
|
|
|
+ <!-- <el-input v-model="sItem.param2" clearable placeholder="请输入" style="width: 100%;" /> -->
|
|
|
+ <el-autocomplete
|
|
|
+ v-model="sItem.param2"
|
|
|
+ class="inline-input"
|
|
|
+ value-key="name"
|
|
|
+ :fetch-suggestions="querySearch"
|
|
|
+ placeholder="请输入"
|
|
|
+ :trigger-on-focus="false"
|
|
|
+ @select="handleSelect"
|
|
|
+ />
|
|
|
</el-col>
|
|
|
<el-col :span="2" class="text-right">
|
|
|
<el-button type="text" icon="el-icon-plus" @click="onAddGZ(index, sIndex)" />
|
|
@@ -272,7 +281,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { ssczAdd, ssczSave } from '@/api/dict'
|
|
|
+import { add_rule } from '@/api/rule/config'
|
|
|
+import { get_all_word_map } from '@/api/dict'
|
|
|
+
|
|
|
export default {
|
|
|
props: {
|
|
|
data: {
|
|
@@ -299,6 +310,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ qcData: [],
|
|
|
ruleForm: {
|
|
|
case_type: '',
|
|
|
changjing: [],
|
|
@@ -386,21 +398,33 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
+ this.getQcData()
|
|
|
if (this.data.row.id) {
|
|
|
- const {
|
|
|
- SSBM,
|
|
|
- SSMC,
|
|
|
- SSLB,
|
|
|
- LRXX,
|
|
|
- id } = this.data.row
|
|
|
- this.ruleForm.ssbm = SSBM
|
|
|
- this.ruleForm.ssmc = SSMC
|
|
|
- this.ruleForm.id = id
|
|
|
- this.ruleForm.sslb = SSLB
|
|
|
- this.ruleForm.lrxx = LRXX
|
|
|
+ // todo
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 搜索质控字典
|
|
|
+ getQcData() {
|
|
|
+ get_all_word_map({ status: 1 }).then(res => {
|
|
|
+ const { p } = res
|
|
|
+ this.qcData = Array.isArray(p) ? p : []
|
|
|
+ })
|
|
|
+ },
|
|
|
+ querySearch(queryString, cb) {
|
|
|
+ var qcData = this.qcData
|
|
|
+ var results = queryString ? qcData.filter(this.createFilter(queryString)) : qcData
|
|
|
+ // 调用 callback 返回建议列表的数据
|
|
|
+ cb(results)
|
|
|
+ },
|
|
|
+ createFilter(queryString) {
|
|
|
+ return (restaurant) => {
|
|
|
+ return (restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSelect(item) {
|
|
|
+ console.log(item)
|
|
|
+ },
|
|
|
// 添加前置条件大框
|
|
|
onAddQZTJ() {
|
|
|
this.ruleForm.qztj.push({
|
|
@@ -444,17 +468,80 @@ export default {
|
|
|
onDeleteGZ(index, sIndex) {
|
|
|
this.ruleForm.rule[index].condition_content.splice(sIndex, 1)
|
|
|
},
|
|
|
+ hasEmptyValues(obj) {
|
|
|
+ return Object.values(obj).some(value => !value)
|
|
|
+ },
|
|
|
+ // 验证前置条件
|
|
|
+ judgeQZTJ() {
|
|
|
+ const { qztj } = this.ruleForm
|
|
|
+ let result = true
|
|
|
+ const e_index = []
|
|
|
+ if (qztj.length) {
|
|
|
+ for (let i = 0; i < qztj.length; i++) {
|
|
|
+ qztj[i].condition_content.map(item => {
|
|
|
+ if (this.hasEmptyValues(item)) {
|
|
|
+ e_index.push(i + 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (e_index.length) {
|
|
|
+ this.$message.error(`请完善前置条件${e_index.join()}`)
|
|
|
+ result = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ },
|
|
|
+ // 验证质控逻辑
|
|
|
+ judgeRule() {
|
|
|
+ const { rule } = this.ruleForm
|
|
|
+ let result = true
|
|
|
+ // 质控逻辑只有一条
|
|
|
+ rule[0].condition_content.map(item => {
|
|
|
+ if (this.hasEmptyValues(item)) {
|
|
|
+ this.$message.error(`请完善质控逻辑`)
|
|
|
+ result = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return result
|
|
|
+ },
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate(async(valid) => {
|
|
|
+ const {
|
|
|
+ case_type,
|
|
|
+ changjing,
|
|
|
+ department,
|
|
|
+ object,
|
|
|
+ type,
|
|
|
+ is_not,
|
|
|
+ description,
|
|
|
+ score,
|
|
|
+ error_level,
|
|
|
+ status,
|
|
|
+ rule_type,
|
|
|
+ rule,
|
|
|
+ qztj
|
|
|
+ } = this.ruleForm
|
|
|
if (valid) {
|
|
|
- if (this.ruleForm.id) {
|
|
|
- ssczSave(this.ruleForm).then(res => {
|
|
|
- this.data.bSwitch = false
|
|
|
- this.$emit('refresh')
|
|
|
- this.$message.success(res.m || '操作成功')
|
|
|
- })
|
|
|
- } else {
|
|
|
- ssczAdd(this.ruleForm).then(res => {
|
|
|
+ if (this.judgeQZTJ() && this.judgeRule()) {
|
|
|
+ const params = {
|
|
|
+ case_type,
|
|
|
+ changjing,
|
|
|
+ department,
|
|
|
+ object,
|
|
|
+ type,
|
|
|
+ is_not,
|
|
|
+ description,
|
|
|
+ score,
|
|
|
+ error_level,
|
|
|
+ status,
|
|
|
+ rule_type,
|
|
|
+ rule: [...rule, ...qztj]
|
|
|
+ }
|
|
|
+ console.log(params)
|
|
|
+ if (this.data.row.id) {
|
|
|
+ params.id = this.data.row.id
|
|
|
+ }
|
|
|
+ add_rule(this.ruleForm).then(res => {
|
|
|
this.data.bSwitch = false
|
|
|
this.$emit('refresh')
|
|
|
this.$message.success(res.m || '操作成功')
|