|
@@ -1,149 +1,55 @@
|
|
|
<!-- 扫码 -->
|
|
|
<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" :before-close="closeFun" draggable
|
|
|
- :close-on-click-modal="false" :close-on-press-escape="false" width="60%">
|
|
|
- <el-form ref="ruleFormRef" :rules="rules" :model="initParam" :inline="true">
|
|
|
- <el-divider content-position="center">药品信息</el-divider>
|
|
|
- <el-form-item :label="item.name" :label-width="formLabelWidth" v-for="(item, index) in data.showDiaData"
|
|
|
- :key="index" :prop="'medicineInfo.' + item.field_name">
|
|
|
- <el-select v-model="initParam.medicineInfo[item.field_name]" :placeholder="'请选择' + item.name"
|
|
|
- class="inputWidth" v-if="[1, 2, 3, 4, 5].includes(item.type)">
|
|
|
- <el-option :label="itemIt.name" :value="itemIt.id" v-for="itemIt, i in item.list" :key="i" />
|
|
|
- </el-select>
|
|
|
- <el-input v-model="initParam.medicineInfo[item.field_name]" autocomplete="off"
|
|
|
- :placeholder="'请输入' + item.name" class="inputWidth" v-if="item.type == 6" />
|
|
|
- <el-input v-model="initParam.medicineInfo[item.field_name]" autocomplete="off"
|
|
|
- :placeholder="'请输入' + item.name" class="inputWidth" v-if="item.type == 7" />
|
|
|
- <el-input v-model="initParam.medicineInfo[item.field_name]" autocomplete="off"
|
|
|
- :placeholder="'请输入' + item.name" class="inputWidth" v-if="item.type == 8" />
|
|
|
- <el-date-picker v-model="initParam.medicineInfo[item.field_name]" type="date" value-format="YYYY-MM-DD"
|
|
|
- :placeholder="'请输入' + item.name" clearable style="width: 200px;" v-if="item.type == 9" />
|
|
|
- <el-date-picker v-model="initParam.medicineInfo[item.field_name]" type="datetime"
|
|
|
- value-format="YYYY-MM-DD HH:mm:ss" :placeholder="'请输入' + item.name" clearable style="width: 200px;"
|
|
|
- v-if="item.type == 10" />
|
|
|
- </el-form-item>
|
|
|
- <el-divider content-position="center">入库信息</el-divider>
|
|
|
- <el-form-item class="el-form-item-main" label="数量" :label-width="formLabelWidth" prop="quantity">
|
|
|
- <el-input v-model.number="initParam.quantity" autocomplete="off" class="inputWidth" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item class="el-form-item-main" label="购进单价" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="initParam.unitPrice" autocomplete="off" class="inputWidth" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item class="el-form-item-main" label="入库日期" :label-width="formLabelWidth" prop="date">
|
|
|
- <el-date-picker v-model="initParam.date" type="date" placeholder="入库日期" value-format="YYYY-MM-DD"
|
|
|
- clearable style="width: 200px;" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item class="el-form-item-main" label="发货单位" :label-width="formLabelWidth">
|
|
|
- <el-autocomplete v-model="initParam.forwardingUnit" :fetch-suggestions="querySearch1" clearable class="inputWidth"
|
|
|
- placeholder="发货单位" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="经办人" :label-width="formLabelWidth" prop="operator">
|
|
|
- <el-autocomplete v-model="initParam.operator" :fetch-suggestions="querySearch" clearable class="inputWidth"
|
|
|
- placeholder="经办人" />
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
+ <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></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>
|
|
|
+ <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">
|
|
|
+ <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 />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
<template #footer>
|
|
|
<span class="dialog-footer">
|
|
|
- <el-button type="primary" @click="submitForm(ruleFormRef)">加入暂存</el-button>
|
|
|
- <el-button @click="showinnerVisible">查看暂存</el-button>
|
|
|
- <el-button type="danger" @click="resetForm(ruleFormRef)">重置数据</el-button>
|
|
|
+ <el-button @click="dialogFormVisible = false">关闭</el-button>
|
|
|
+ <el-button type="primary" @click="subStock">立即入库</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
- <el-dialog v-model="innerVisible" title="入库数据" width="95%" append-to-body draggable
|
|
|
- :close-on-click-modal="false" :close-on-press-escape="false">
|
|
|
- <el-table :data="data.tableData" style="width: 100%" border max-height="450"
|
|
|
- :header-cell-style="{ 'background-color': '#ccc', 'color': 'white' }">
|
|
|
- <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">
|
|
|
- <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 />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <template #footer>
|
|
|
- <span class="dialog-footer">
|
|
|
- <el-button @click="innerVisible = false">关闭</el-button>
|
|
|
- <el-button type="primary" @click="subStock">立即入库</el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { reactive, ref ,onMounted} from 'vue'
|
|
|
-import type { FormInstance, FormRules } from 'element-plus'
|
|
|
-import { ElNotification } from 'element-plus'
|
|
|
-import { syrulesData, columnsTable } from "@/plugins/rulesData";
|
|
|
+import { reactive, ref } from 'vue'
|
|
|
+import type { FormInstance } from 'element-plus'
|
|
|
+import inputSearch from "./inputSearch.vue";
|
|
|
const dialogFormVisible = ref(false)
|
|
|
const ruleFormRef = ref<FormInstance>()
|
|
|
-
|
|
|
-let rules: any = reactive({})
|
|
|
+ import { Search } from '@element-plus/icons-vue'
|
|
|
|
|
|
import {
|
|
|
medicListStock,
|
|
|
- stockunit,//发货单位
|
|
|
- operatorList,//经办人
|
|
|
- stockTemplateIn,//单个入库
|
|
|
- stockTemplateBatchIn,//批量入库
|
|
|
} from "@/api";
|
|
|
const innerVisible = ref(false)
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { Delete, Edit, } from '@element-plus/icons-vue'
|
|
|
-const formLabelWidth = '110px'
|
|
|
-let initParam: any = reactive({
|
|
|
- "date": "",
|
|
|
- "forwardingUnit": "",
|
|
|
- "medicineInfo": {},
|
|
|
- "operator": '',
|
|
|
- "quantity": null,
|
|
|
- "unitPrice": null
|
|
|
-})
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-interface RestaurantItem {
|
|
|
- value: string
|
|
|
- link: string
|
|
|
-}
|
|
|
-const restaurants = ref<RestaurantItem[]>([])
|
|
|
-const querySearch = (queryString: string, cb: any) => {
|
|
|
- const results = queryString
|
|
|
- ? restaurants.value.filter(createFilter(queryString))
|
|
|
- : restaurants.value
|
|
|
- cb(results)
|
|
|
-}
|
|
|
-const createFilter = (queryString: string) => {
|
|
|
- return (restaurant: RestaurantItem) => {
|
|
|
- return (
|
|
|
- restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
|
|
- )
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-const restaurants1 = ref<RestaurantItem[]>([])
|
|
|
-const querySearch1 = (queryString: string, cb: any) => {
|
|
|
- const results = queryString
|
|
|
- ? restaurants1.value.filter(createFilter(queryString))
|
|
|
- : restaurants1.value
|
|
|
- cb(results)
|
|
|
-}
|
|
|
-
|
|
|
+import { syrulesData, columnsTable } from "@/plugins/rulesData";
|
|
|
let data: any = reactive({
|
|
|
tableData: [],
|
|
|
showDiaData: [],
|
|
@@ -154,136 +60,25 @@ let data: any = reactive({
|
|
|
editStrot: false,
|
|
|
editIndex: null
|
|
|
})
|
|
|
-const emit: any = defineEmits(['scanCode'])
|
|
|
-//立即入库
|
|
|
-const subStock = async () => {
|
|
|
- const reslut: any = await stockTemplateBatchIn({ "stockInList": data.tableData })
|
|
|
- console.log('返回', reslut)
|
|
|
- if (reslut.code == 200 && reslut.msg == '入库成功') {
|
|
|
- ElMessage.success(reslut.msg)
|
|
|
- dialogFormVisible.value = false
|
|
|
- innerVisible.value = false
|
|
|
- emit('scanCode', '')
|
|
|
- data.tableData = []
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//函数
|
|
|
-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
|
|
|
- }
|
|
|
-}
|
|
|
-const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return
|
|
|
- formEl.resetFields()
|
|
|
-}
|
|
|
-//加入暂存区
|
|
|
-const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return
|
|
|
- await formEl.validate((valid, fields) => {
|
|
|
- if (valid) {
|
|
|
- ElNotification({
|
|
|
- title: '暂存成功',
|
|
|
- message: 'ok,加入暂存成功,右下角按钮查看/提交暂存',
|
|
|
- type: 'success',
|
|
|
- })
|
|
|
- console.log('提交', data.editStrot)
|
|
|
- if (data.editStrot) {//编辑状态
|
|
|
- let { date, forwardingUnit, operator, quantity, unitPrice, medicineInfo } = initParam
|
|
|
- data.tableData.splice(data.editIndex, 1, { date, forwardingUnit, operator, quantity, unitPrice: parseInt(unitPrice), medicineInfo: { ...medicineInfo } })
|
|
|
- console.log('编辑状态', data.tableData)
|
|
|
- } else {//正常添加
|
|
|
- let { date, forwardingUnit, operator, quantity, unitPrice, medicineInfo } = initParam
|
|
|
- data.tableData.push({ date, forwardingUnit, operator, quantity, unitPrice: parseInt(unitPrice), medicineInfo: { ...medicineInfo } })
|
|
|
- console.log('正常添加', data.tableData)
|
|
|
- }
|
|
|
- } else {
|
|
|
- ElMessage.error('请完善必填项')
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-//函数
|
|
|
-const closeFun = async () => {
|
|
|
- if (data.tableData.length == 0) {
|
|
|
- dialogFormVisible.value = false
|
|
|
- data.tableData = []
|
|
|
- } else {
|
|
|
- ElMessageBox.confirm('请检查录入数据是否已经提交,该操作将放弃录入信息,是否放弃?', '提示', {
|
|
|
- confirmButtonText: '立即去入库',
|
|
|
- cancelButtonText: '放弃数据',
|
|
|
- type: 'warning',
|
|
|
- draggable: true,
|
|
|
- center: true,
|
|
|
- }).then(() => {
|
|
|
- innerVisible.value = true
|
|
|
- }).catch(() => {
|
|
|
- dialogFormVisible.value = false
|
|
|
- ElMessage.success('已放弃入库数据')
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
-//收发货单位
|
|
|
-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
|
|
|
-}
|
|
|
-//经办人Api
|
|
|
-const operatorListApi = async () => {
|
|
|
- const reslut: any = await operatorList({})
|
|
|
- const arrMap = reslut.data?.list
|
|
|
- const arr:any = []
|
|
|
- arrMap.forEach((item:any)=>{
|
|
|
- arr.push({ value: item, link: item})
|
|
|
- })
|
|
|
- restaurants.value = arr
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-//函数
|
|
|
-const showinnerVisible = async () => {
|
|
|
- innerVisible.value = true
|
|
|
- data.editStrot = false
|
|
|
- console.log(data.tableData)
|
|
|
-}
|
|
|
-
|
|
|
+let initParam: any = reactive({
|
|
|
+ "date": "",
|
|
|
+ "forwardingUnit": "",
|
|
|
+ "medicineInfo": {},
|
|
|
+ "operator": '',
|
|
|
+ "quantity": '',
|
|
|
+ "unitPrice": null
|
|
|
+})
|
|
|
+let rules: any = reactive({})
|
|
|
const showDia = async () => {
|
|
|
- data.tableData = []
|
|
|
- data.showDiaData = []
|
|
|
- data.rules1 = []
|
|
|
- data.columns = []
|
|
|
- data.selectType = []
|
|
|
- data.editStrot = false
|
|
|
- resetFun()//复原表单
|
|
|
-
|
|
|
+ dialogFormVisible.value = true
|
|
|
medicListStockFun()//获取入库表单
|
|
|
- itemPirFun()//发货单位
|
|
|
- operatorListApi()//经办人
|
|
|
-}
|
|
|
-//复原表单
|
|
|
-const resetFun = async () => {
|
|
|
- initParam.date = ''
|
|
|
- initParam.forwardingUnit = ''
|
|
|
- initParam.medicineInfo = {}
|
|
|
- initParam.operator = ''
|
|
|
- initParam.quantity = null
|
|
|
- initParam.unitPrice = null
|
|
|
- resetForm(ruleFormRef.value)
|
|
|
}
|
|
|
//获取入库表单Api
|
|
|
const medicListStockFun = async () => {
|
|
|
data.columns = []
|
|
|
const reslut: any = await medicListStock({})
|
|
|
+ console.log('表格', reslut)
|
|
|
+ return
|
|
|
if (reslut.code == 200 && reslut.msg == '查询成功') {
|
|
|
data.showDiaData = reslut.data?.list
|
|
|
data.rules1 = {}
|
|
@@ -309,26 +104,9 @@ const medicListStockFun = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const handleClick = (datas: any, index: any) => {
|
|
|
- data.editStrot = true
|
|
|
- data.editIndex = index
|
|
|
- let { date, forwardingUnit, operator, quantity, unitPrice, medicineInfo } = datas
|
|
|
- Object.assign(initParam, { date, forwardingUnit, operator, quantity, unitPrice, medicineInfo: { ...medicineInfo } })
|
|
|
- innerVisible.value = false
|
|
|
-}
|
|
|
-const delClick = (index: any) => {
|
|
|
- ElMessageBox.confirm('删除一条信息,是否继续?', '删除', {
|
|
|
- confirmButtonText: '确认删除',
|
|
|
- cancelButtonText: 'Cancel',
|
|
|
- type: 'warning',
|
|
|
- center: true,
|
|
|
- }).then(() => {
|
|
|
- data.tableData.splice(index, 1);
|
|
|
- ElMessage.success('已删除')
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
</script>
|
|
|
-<style lang="scss">.inputWidth {
|
|
|
+<style lang="scss">
|
|
|
+.inputWidth {
|
|
|
width: 200px;
|
|
|
}</style>
|