|
@@ -0,0 +1,225 @@
|
|
|
+<!-- 运输扫码 -->
|
|
|
+<template>
|
|
|
+ <div class="">
|
|
|
+ <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" placeholderData="请扫描运输条码" style="margin:0 auto 40px auto;" @inputSearchData="inputSearchfn"></inputSearch>
|
|
|
+ <el-table :data="data.tableData" style="width: 100%" border height="450" row-class-name="success-row">
|
|
|
+ <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[item.prop] }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="item.label" min-width="150" v-for="item,index in TranscanCodeTable" :key="index"
|
|
|
+ :fixed="item.prop == 'operation'&&'right'">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input v-if="['quantity','unit_price'].includes(item.prop)" v-model="scope.row[item.prop]" style="width: 100px;"/>
|
|
|
+ <el-autocomplete v-if="item.prop == 'operator'" v-model="scope.row[item.prop]"
|
|
|
+ :fetch-suggestions="querySearch2" clearable style="width: 120px;" />
|
|
|
+ <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="danger" @click="resetForm">重置数据</el-button>
|
|
|
+ <el-button type="primary" :disabled="data.tableData.length==0?true:false" @click="subStock">立即入库</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { reactive, ref,nextTick,watch, onMounted} from 'vue'
|
|
|
+import inputSearch from "./inputSearch.vue";
|
|
|
+import {TranscanCodeTable } from "@/plugins/rulesData";
|
|
|
+import { timesFn } from "@/plugins/settime";
|
|
|
+
|
|
|
+
|
|
|
+const dialogFormVisible = ref(false)
|
|
|
+watch(() => dialogFormVisible.value, (dy: any) => {
|
|
|
+ if(!dy)resetForm()
|
|
|
+})
|
|
|
+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 {
|
|
|
+ medicListScanCode,
|
|
|
+ medicTransport,
|
|
|
+ operatorList
|
|
|
+} from "@/api";
|
|
|
+let data: any = reactive({
|
|
|
+ tableData: [],
|
|
|
+ showDiaData: [],
|
|
|
+ itemPir: [],
|
|
|
+ rules1: {},
|
|
|
+ columns: [],// 渲染表格
|
|
|
+ selectType: [],//表格的下拉对应
|
|
|
+ editStrot: false,
|
|
|
+ editIndex: null,
|
|
|
+ qr:''
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+let rules: any = reactive({})
|
|
|
+const showDia = async () => {
|
|
|
+ dialogFormVisible.value = true
|
|
|
+ medicListStockFun()//获取入库表单
|
|
|
+ itemPirFun()
|
|
|
+ itemPirFun2()
|
|
|
+ nextTick(()=>{
|
|
|
+ console.log('inputSearchRef',inputSearchRef.value)
|
|
|
+ inputSearchRef.value?.inputFocus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//获取入库表单Api
|
|
|
+const medicListStockFun = async () => {
|
|
|
+ data.columns = []
|
|
|
+ const reslut: any = await medicListScanCode({})
|
|
|
+ console.log('表格888', reslut)
|
|
|
+ if (reslut.code == 200 && reslut.msg == '查询成功') {
|
|
|
+ data.showDiaData = reslut.data?.list
|
|
|
+ data.rules1 = {}
|
|
|
+ data.columns = []
|
|
|
+ reslut.data?.list.forEach((value: any) => { //value设置成key
|
|
|
+ data.columns.push({ prop: value.field_name, label: value.name, list: value.list })
|
|
|
+ // initParam.medicineInfo[value.field_name] = ''; // 这里可以根据需要设置其他值作为键的内容
|
|
|
+ });
|
|
|
+ Object.assign(rules, { ...data.rules1, ...syrulesData })
|
|
|
+ dialogFormVisible.value = true
|
|
|
+ }
|
|
|
+}
|
|
|
+const emit: any = defineEmits(['scanCode'])
|
|
|
+const subStock = async ()=>{
|
|
|
+ const ab = data.tableData.every((item:any) => item.quantity != '' && item.operator != '' && item.date != '')
|
|
|
+ if(!ab){ElMessage.error('缺少数据提示:【数量】、【经办人】、【入库日期】是必填项哦!');return;}
|
|
|
+ else{
|
|
|
+ const arr = [...data.tableData]
|
|
|
+ let arrData:any = []
|
|
|
+ arr.forEach((item:any)=>{
|
|
|
+ item.quantity = Number(item.quantity)
|
|
|
+ item.unit_price = Number(item.unit_price)
|
|
|
+ arrData.push({
|
|
|
+ date:item.date,
|
|
|
+ forwardingUnit:item.forwardingUnit,
|
|
|
+ medicineInfo:item,
|
|
|
+ operator:item.operator,
|
|
|
+ quantity:item.quantity,
|
|
|
+ unitPrice:item.unit_price
|
|
|
+ })
|
|
|
+ })
|
|
|
+ const reslut:any = await stockCodein({stockInList:arrData})
|
|
|
+ if(reslut.code==200){
|
|
|
+ ElMessage.success(reslut.msg)
|
|
|
+ dialogFormVisible.value = false
|
|
|
+ emit('scanCode', '')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 搜索
|
|
|
+ * @param e 追溯码
|
|
|
+ */
|
|
|
+const inputSearchfn = async (e:any)=>{
|
|
|
+ data.qr = e
|
|
|
+ const reslut:any = await medicTransport({code:e})
|
|
|
+ if (reslut.code==200 && reslut.msg=='查询成功') {
|
|
|
+ console.log('reslut.data',reslut.data)
|
|
|
+ let arr = [... reslut.data] || []
|
|
|
+ arr.forEach((item:any)=>{ item.date = timesFn()})
|
|
|
+ data.tableData = [...arr]
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 删除
|
|
|
+ * @param index
|
|
|
+ */
|
|
|
+const deltable = async (index:any)=>{
|
|
|
+ data.tableData.splice(index,1)
|
|
|
+ nextTick(()=>{
|
|
|
+ inputSearchRef.value?.inputFocus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//经半人
|
|
|
+const itemPirFun2 = async () => {
|
|
|
+ const reslut: any = await operatorList({})
|
|
|
+ const arrMap = reslut.data?.list
|
|
|
+ const arr:any = []
|
|
|
+ arrMap.forEach((item:any)=>{
|
|
|
+ arr.push({ value: item, link: item})
|
|
|
+ })
|
|
|
+ restaurants2.value = arr
|
|
|
+}
|
|
|
+const restaurants2 = ref<RestaurantItem[]>([])
|
|
|
+const querySearch2 = (queryString: string, cb: any) => {
|
|
|
+ const results = queryString
|
|
|
+ ? restaurants2.value.filter(createFilter(queryString))
|
|
|
+ : restaurants2.value
|
|
|
+ cb(results)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//收发货单位
|
|
|
+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
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 重置
|
|
|
+ */
|
|
|
+const resetForm = async ()=>{
|
|
|
+ data.tableData = []
|
|
|
+ inputSearchRef?.value?.ClearFn()
|
|
|
+ inputSearchRef.value?.inputFocus()
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss">
|
|
|
+.inputWidth {
|
|
|
+ width: 200px;
|
|
|
+}
|
|
|
+.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>
|