YangJian0701 1 year ago
parent
commit
5e256f02f0

+ 11 - 0
src/api/module/storagePut.ts

@@ -41,3 +41,14 @@ export const medicListStock = (params: any) => $http.post('/medicine-template/li
 export const operatorList = (params: any) => $http.post('/stock/operator/list', params)
 
 
+export const medicListScanCode = (params: any) => $http.post('/medicine-template/scan-code/stock-in-list', params)
+
+/**
+ * 获取马上放心
+ * @param params 
+ * @returns 
+ */
+export const medicMsfx = (params: any) => $http.post('/medicine/msfx-query', params)
+
+export const stockCodein = (params: any) => $http.post('/stock-template/scan-code-in', params)
+

+ 6 - 1
src/plugins/rulesData.ts

@@ -21,11 +21,16 @@ export let columnsTable = [
     { prop: 'quantity', label: '数量', width: 0 },
     { prop: 'unit_price', label: '购进单价', width: 0 },
     { prop: 'operator', label: '经办人', width: 0 },
-    { prop: 'forwarding_unit', label: '发货单位', width: 0 },
+    // { prop: 'forwarding_unit', label: '发货单位', width: 0 },
+    { prop: 'forwardingUnit', label: '发货单位', width: 0 },
+
+    
     { prop: 'date', label: '入库日期', width: 0 },
     { prop: 'operation', label: '操作', fixed: 'right',"min-width":200}
 ]
 
+
+
 //出库
 export let columnsTableOut = [
     { label: '数量', prop: 'quantity', width: 0 },

+ 42 - 22
src/views/stockcontrol/storagePut/inputSearch.vue

@@ -4,46 +4,62 @@
             <img src="@/assets/img/BarCodeQR.svg" style="width: 80%;height: 80%;">
         </div>
         <div class="Qr-input">
-            <input class="Qr-input-type" ref="myInput" v-model="data.value" type="text" placeholder="请扫描追数码">
-            <el-icon :size="18" style="cursor: pointer;" @click="data.value = ''"><CircleClose/></el-icon>
+            <input class="Qr-input-type" ref="myInput" v-model="data.value" type="text" placeholder="请扫描追数码" >
+            <el-icon :size="18" style="cursor: pointer;" @click="CloseFn">
+                <CircleClose />
+            </el-icon>
         </div>
-        <button class="Qr-isButton">确认</button>
+        <button class="Qr-isButton" @click="onSubmit">确认搜索</button>
     </div>
 </template>
 
 <script setup lang="ts">
-import { ref,reactive} from "vue";
+import { ref, reactive } from "vue";
+import { ElMessage, ElMessageBox } from 'element-plus'
 const myInput = ref()
-const data:any = reactive({
-    value:''
+const data: any = reactive({
+    value: ''
 })
+const emit: any = defineEmits(['inputSearchData',])
 //函数
-const inputFocus = async ()=>{
-    setTimeout(()=>{
+const inputFocus = async () => {
+    setTimeout(() => {
         myInput.value.focus()
-    },1000)
+    }, 1000)
+}
+//函数
+const CloseFn = async () => {
+    data.value = '';
+    setTimeout(() => {
+        myInput.value.focus()
+    }, 1000)
+}
+//函数
+const onSubmit = async () => {
+    data.value ? emit('inputSearchData', data.value) : ElMessage.error('点击输入框在使用扫码枪扫码')
 }
 defineExpose({
-    inputFocus
+    inputFocus, data
 })
 </script>
 <style lang="scss">
 /* @import url(); 引入css类 */
-.Qr{
+.Qr {
     display: flex;
     margin-bottom: 20px;
     border: 1px solid #409eff;
     box-sizing: border-box;
-    min-width:450px;
-    width: 30%;
+    min-width: 450px;
+    width: 50%;
     border-radius: 6px;
     overflow: hidden;
-    &-img{
+
+    &-img {
         width: 30px;
         height: 30px;
         margin-top: 10px;
         margin-bottom: 10px;
-        padding:0 20px;
+        padding: 0 20px;
         flex-shrink: 0;
         display: flex;
         align-items: center;
@@ -51,20 +67,23 @@ defineExpose({
         border-right: .5px solid #409eff;
         user-select: none;
     }
-    &-input{
+
+    &-input {
         flex: 1;
         padding: 0 20px;
         display: flex;
         align-items: center;
-        &-type{
+
+        &-type {
             outline: none;
             border: none;
             flex: 1;
             font-weight: bold;
-        font-size: 18px;
+            font-size: 18px;
         }
     }
-    &-isButton{
+
+    &-isButton {
         background: #409eff;
         outline: none;
         border: none;
@@ -74,11 +93,12 @@ defineExpose({
         cursor: pointer;
         user-select: none;
     }
-    &-isButton:hover{
+
+    &-isButton:hover {
         background: #a0cfff;
     }
+
     &-isButton:active {
         background-color: #337ecc;
     }
-}
-</style>
+}</style>

+ 143 - 41
src/views/stockcontrol/storagePut/scanCode.vue

@@ -4,31 +4,28 @@
         <el-button el-button type="primary" icon="Camera" @click="showDia">扫码入库</el-button>
         <el-dialog v-model="dialogFormVisible" title="扫码入库" :append-to-body="true" draggable :close-on-click-modal="false"
             :close-on-press-escape="false" width="95%">
-            <inputSearch ref="inputSearchRef"></inputSearch>
-            <el-table :data="data.tableData" style="width: 100%" border height="450">
-                <el-table-column :label="item.label" v-for="item, i in data.columns" :key="i" min-width="110"
-                    show-overflow-tooltip>
+            <inputSearch ref="inputSearchRef" style="margin:0 auto 40px auto;" @inputSearchData="inputSearchfn"></inputSearch>
+            <el-table :data="data.tableData" style="width: 100%" border height="450" :row-class-name="tableRowClassName">
+                <el-table-column :label="item.label" v-for="item, i in data.columns" :key="i" min-width="110" show-overflow-tooltip>
                     <template #default="scope"><!--scope.row.medicineInfo[item.prop] -->
                         {{ findFun(scope.row.medicineInfo[item.prop], item.list) }}
                     </template>
                 </el-table-column>
-                <el-table-column prop="quantity" label="数量" min-width="110" show-overflow-tooltip />
-                <el-table-column prop="unitPrice" label="购进单价" min-width="110" show-overflow-tooltip />
-                <el-table-column prop="forwardingUnit" label="发货单位" min-width="110" show-overflow-tooltip />
-                <el-table-column prop="date" label="入库日期" min-width="110" show-overflow-tooltip />
-                <el-table-column prop="operator" label="经办人" min-width="110" show-overflow-tooltip />
-
-                <el-table-column fixed="right" label="操作" min-width="110">
+                <el-table-column :label="item.label" min-width="150" v-for="item,index in columnsTable" :key="index"
+                :fixed="item.prop == 'operation'&&'right'">
                     <template #default="scope">
-                        <el-button type="primary" :icon="Edit" @click="handleClick(scope.row, scope.$index)" circle />
-                        <el-button type="danger" :icon="Delete" @click="delClick(scope.$index)" circle />
+                        <el-input v-if="['quantity','unit_price','operator'].includes(item.prop)" v-model="scope.row[item.prop]" style="width: 100px;"/>
+                        <el-date-picker v-if="item.prop == 'date'" v-model="scope.row[item.prop]" type="date" value-format="YYYY-MM-DD" style="width: 120px;"/>
+                        <el-autocomplete v-if="item.prop == 'forwardingUnit'" v-model="scope.row[item.prop]"
+                         :fetch-suggestions="querySearch1" clearable style="width: 120px;" />
+                        <el-button v-if="item.prop == 'operation'" type="danger" :icon="Delete" @click="deltable(scope.$index)">删除</el-button>
                     </template>
                 </el-table-column>
             </el-table>
             <template #footer>
                 <span class="dialog-footer">
                     <el-button @click="dialogFormVisible = false">关闭</el-button>
-                    <el-button type="primary" @click="subStock">立即入库</el-button>
+                    <el-button type="primary" :disabled="data.tableData.length==0?true:false" @click="subStock">立即入库</el-button>
                 </span>
             </template>
         </el-dialog>
@@ -36,21 +33,23 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, ref } from 'vue'
-import type { FormInstance } from 'element-plus'
+import { reactive, ref,nextTick,watch, onMounted} from 'vue'
 import inputSearch from "./inputSearch.vue";
+import { columnsTable } from "@/plugins/rulesData";
 const dialogFormVisible = ref(false)
-const ruleFormRef = ref<FormInstance>()
 const inputSearchRef = ref<InstanceType<typeof inputSearch> | null>(null)
+import { 
+    stockunit,//收发货单位
+    stockCodein
+} from "@/api";
+import { ElMessage } from 'element-plus'
+import { Delete} from '@element-plus/icons-vue'
+import { syrulesData } from "@/plugins/rulesData";
 
-    
 import {
-    medicListStock,
+    medicListScanCode,
+    medicMsfx
 } from "@/api";
-const innerVisible = ref(false)
-import { ElMessage, ElMessageBox } from 'element-plus'
-import { Delete, Edit, } from '@element-plus/icons-vue'
-import { syrulesData, columnsTable } from "@/plugins/rulesData";
 let data: any = reactive({
     tableData: [],
     showDiaData: [],
@@ -59,7 +58,8 @@ let data: any = reactive({
     columns: [],// 渲染表格
     selectType: [],//表格的下拉对应
     editStrot: false,
-    editIndex: null
+    editIndex: null,
+    qr:''
 })
 let initParam: any = reactive({
     "date": "",
@@ -69,47 +69,149 @@ let initParam: any = reactive({
     "quantity": '',
     "unitPrice": null
 })
+
+/**
+ * 当前搜索到的样式
+ * @param param0 
+ */
+const tableRowClassName = ({rowIndex}: {
+  rowIndex: number
+}) => {
+    if(data.qr){
+        const i = data.tableData.findIndex((item:any) => item.Qrcode==data.qr)
+        if (rowIndex==i) { return 'success-row' }else{return ''}
+    }else{
+        return ''
+    }
+}
+
 let rules: any = reactive({})
 const showDia = async () => {
-    console.log('inputSearchRef',inputSearchRef.value)
     dialogFormVisible.value = true
     medicListStockFun()//获取入库表单
-    inputSearchRef.value?.inputFocus()
+    itemPirFun()
+    nextTick(()=>{
+        console.log('inputSearchRef',inputSearchRef.value)
+        inputSearchRef.value?.inputFocus()
+    })
 }
+//函数
+const findFun = (data: any, list: any) => {
+    if (list) {
+        const b = list.find((item: any) => item.id == data)
+        if (b) return b.name
+        else return ''
+    } else {
+        return data
+    }
+}
+
 //获取入库表单Api
 const medicListStockFun = async () => {
     data.columns = []
-    const reslut: any = await medicListStock({})
+    const reslut: any = await medicListScanCode({})
     console.log('表格', reslut)
-    return
     if (reslut.code == 200 && reslut.msg == '查询成功') {
         data.showDiaData = reslut.data?.list
         data.rules1 = {}
         data.columns = []
-        data.selectType = []
         reslut.data?.list.forEach((value: any) => { //value设置成key
-            data.selectType.push({ type: value.type, list: value.list })
             data.columns.push({ prop: value.field_name, label: value.name, list: value.list })
             initParam.medicineInfo[value.field_name] = ''; // 这里可以根据需要设置其他值作为键的内容
-            if (['product_id', 'enterprise_id', 'spec_id', 'batch_number', 'expiry_date', 'approval_number'].includes(value.field_name)) {
-                if (value.type == 6) {
-                    data.rules1['medicineInfo.' + value.field_name] = [{ required: true, message: '必填项', trigger: 'change' }, { pattern: /^([1-9]\d*|0)(\.\d{1,2})?$/, message: '请输入>=0,(最多两位小数)', trigger: "blur" },]
-                } else if (value.type == 7) {
-                    data.rules1['medicineInfo.' + value.field_name] = [{ required: true, message: '必填项', trigger: 'change' }, { pattern: /^(?:[1-9]\d*)$/, message: '请输入正整数', trigger: "blur" },]
-                } else {
-                    data.rules1['medicineInfo.' + value.field_name] = [{ required: true, message: '必填项', trigger: 'change', }]
-                }
-            }
         });
         Object.assign(rules, { ...data.rules1, ...syrulesData })
-        console.log('表格', data.selectType)
         dialogFormVisible.value = true
     }
 }
 
+const subStock = async ()=>{
+    const ab = data.tableData.every((item:any) => item.quantity != '' && item.operator != '')
+    if(!ab){ElMessage.error('缺少数据提示:【数量】与【经办人】是必填项哦!');return;}
+    else{
+        const reslut:any = await stockCodein(data.tableData)
+        console.log('添加成功')
+        if(reslut.code==200){
+            ElMessage.success(reslut.msg)
+        }
+    }
+}
+/**
+ * 搜索
+ * @param e 追溯码
+ */
+const inputSearchfn = async (e:any)=>{
+    data.qr = e
+    const j = await SearchFind(e)
+    if (j) {ElMessage.error('提示:重复扫描添加数据了哦');return}
+    const reslut:any = await medicMsfx({code:e})
+    let initParamObj = {...initParam}
+    initParamObj.Qrcode = e
+    if (reslut.code==200 && reslut.msg=='查询成功') {
+        initParamObj.medicineInfo = reslut.data[0] || {}
+        data.tableData.push(initParamObj)
+        inputSearchRef.value?.inputFocus()
+    }
+}
+/**
+ * 筛选是否已经扫描过
+ * @param j 追溯码 
+ */
+const SearchFind = (j:any)=>{
+    return new Promise(resolve=>{
+        const ab = data.tableData.find((item:any) => item.Qrcode==j)
+        ab==undefined?resolve(false):resolve(true)
+    })
+}
+
+/**
+ * 删除
+ * @param index 
+ */
+const deltable = async (index:any)=>{
+    data.tableData.splice(index,1)
+    nextTick(()=>{
+        inputSearchRef.value?.inputFocus()
+    })
+}
+
+//收发货单位
+const itemPirFun = async () => {
+    const reslut: any = await stockunit({ type: 3 })
+    const arrMap = reslut.data?.list
+    const arr:any = []
+    arrMap.forEach((item:any)=>{
+        arr.push({ value: item, link: item})  
+    })
+    restaurants1.value = arr
+}
+interface RestaurantItem {
+  value: string
+  link: string
+}
+const restaurants1 = ref<RestaurantItem[]>([])
+const querySearch1 = (queryString: string, cb: any) => {
+  const results = queryString
+    ? restaurants1.value.filter(createFilter(queryString))
+    : restaurants1.value
+  cb(results)
+}
+const createFilter = (queryString: string) => {
+  return (restaurant: RestaurantItem) => {
+    return (
+      restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
+    )
+  }
+}
 
 </script>
 <style lang="scss">
 .inputWidth {
     width: 200px;
-}</style>
+}
+.el-table .warning-row {
+  --el-table-tr-bg-color: var(--el-color-warning-light-9);
+}
+.el-table .success-row {
+  --el-table-tr-bg-color: var(--el-color-success-light-9);
+}
+</style>