|
@@ -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>
|