Browse Source

检查部位字典维护

lighter 3 weeks ago
parent
commit
9017fd830a

+ 24 - 0
src/api/dictionary/jc-part-maintain.js

@@ -0,0 +1,24 @@
+import request from '../../utils/request'
+
+export function getAllJcPart() {
+  return request({
+    url: '/jcPartMaintain/getAllJcPart',
+    method: 'get',
+  })
+}
+
+export function insertNewPart(data) {
+  return request({
+    url: '/jcPartMaintain/insertNewPart',
+    method: 'post',
+    data
+  })
+}
+
+export function updatePart(data) {
+  return request({
+    url: '/jcPartMaintain/updatePart',
+    method: 'post',
+    data
+  })
+}

+ 169 - 0
src/views/dictionary/JcPartMaintain.vue

@@ -0,0 +1,169 @@
+<template>
+  <div class="layout_container">
+    <header class="round-header">
+      <el-button
+          style="width: 100%"
+          size="large"
+          type="primary"
+          plain
+          @click="clickAdd"
+      >
+        + 新增部位
+      </el-button>
+    </header>
+    <div class="layout_main layout_el-table">
+      <el-table
+          :data="cptJcPart"
+          stripe
+          highlight-current-row
+      >
+        <el-table-column prop="code" label="编码" />
+        <el-table-column prop="name" label="名称" width="220">
+          <template #header>
+            名称
+            <el-input
+                suffix-icon="Search"
+                style="width: 160px"
+                v-model="nameInput"
+                placeholder="输入 首拼/名称 检索"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column prop="parentName" label="检查类别" />
+        <el-table-column label="状态">
+          <template #default="{row}">
+            <span v-html="coloredStatus(row.delFlag)"></span>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作">
+          <template #default="{row}">
+            <el-button
+                icon="Edit"
+                type="primary"
+                plain
+                @click="clickEdit(row)"
+            >
+              编辑
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <el-dialog
+        v-model="showDialog"
+        width="300px"
+        :title="dialogTitle"
+    >
+      <el-form label-width="60">
+        <el-form-item label="编码">
+          <el-input
+              v-model="jcPart.code"
+              placeholder="由系统自动生成"
+              disabled
+          />
+        </el-form-item>
+        <el-form-item label="名称" required>
+          <el-input v-model="jcPart.name"/>
+        </el-form-item>
+        <el-form-item label="检查类别">
+          <el-select
+            v-model="jcPart.parentCode"
+            clearable
+            filterable
+          >
+            <el-option
+                v-for="item in allJcClass"
+                :label="item.name"
+                :value="item.code"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="状态" required>
+          <el-select
+              v-model="jcPart.delFlag"
+          >
+            <el-option label="正常" value="0" />
+            <el-option label="停用" value="1" />
+          </el-select>
+        </el-form-item>
+      </el-form>
+
+      <template #footer>
+        <el-button @click="showDialog = false">取消</el-button>
+        <el-button type="success" @click="clickConfirm">保存</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup>
+import {getAllJcPart, insertNewPart, updatePart} from "@/api/dictionary/jc-part-maintain.js";
+import {xcMessage} from "@/utils/xiaochan-element-plus";
+
+const nameInput = ref('')
+const allJcPart = ref([])
+const allJcClass = ref([])
+
+const cptJcPart = computed(() => {
+  return allJcPart.value.filter((item) => {
+    return item.name.indexOf(nameInput.value) !== -1
+        || item.pyCode.indexOf(nameInput.value) !== -1
+  })
+})
+
+function coloredStatus(delFlag) {
+  return delFlag === '1' ?
+      '<span style="color: red">停用</span>' :
+      '<span style="color: green">正常</span>'
+}
+
+const jcPart = reactive({
+  code: null,
+  name: null,
+  delFlag: null,
+  parentCode: null,
+})
+
+const showDialog = ref(false)
+const dialogTitle = ref('')
+function clickAdd() {
+  jcPart.code = null
+  jcPart.name = null
+  jcPart.delFlag = '0'
+  jcPart.parentCode = null
+  dialogTitle.value = '添加部位'
+  showDialog.value = true
+}
+
+function clickEdit(row) {
+  jcPart.code = row.code
+  jcPart.name = row.name
+  jcPart.delFlag = row.delFlag
+  jcPart.parentCode = row.parentCode
+  dialogTitle.value = '编辑部位'
+  showDialog.value = true
+}
+
+function clickConfirm() {
+  if (jcPart.code === null) {
+    insertNewPart(jcPart).then((res) => {
+      allJcPart.value = res
+      xcMessage.success('添加成功')
+    })
+  } else {
+    updatePart(jcPart).then((res) => {
+      allJcPart.value = res
+      xcMessage.success('修改成功')
+    })
+  }
+  showDialog.value = false
+}
+
+onMounted(() => {
+  getAllJcPart().then((res) => {
+    console.log(res)
+    allJcPart.value = res.jcPartList
+    allJcClass.value = res.jcClassList
+  })
+})
+</script>

+ 0 - 1
src/views/dictionary/ShouShuBuWeiWeiHu.vue

@@ -47,7 +47,6 @@ import {computed} from 'vue'
 import {stringIsBlank} from '@/utils/blank-utils'
 import {ElMessage} from 'element-plus'
 
-const innerHeight = window.innerHeight
 const shouShuBuWeiBianMa = ref('')
 const shuJu = ref({
   data: [],