|
@@ -0,0 +1,189 @@
|
|
|
|
+<template>
|
|
|
|
+ <my-dialog
|
|
|
|
+ :visible="visible"
|
|
|
|
+ @close="emit('update:visible', false)"
|
|
|
|
+ header="新增设备出入库信息"
|
|
|
|
+ :width="1100"
|
|
|
|
+ :closeOnOverlayClick="false"
|
|
|
|
+ >
|
|
|
|
+ <t-form ref="formRef" :model="formData" :labelWidth="120">
|
|
|
|
+ <t-row :gutter="[0, 20]">
|
|
|
|
+ <t-col :span="6">
|
|
|
|
+ <t-form-item label="设备出入库选择">
|
|
|
|
+ <t-radio-group v-model="formData.a" style="width: 100%">
|
|
|
|
+ <t-radio value="1">出库</t-radio>
|
|
|
|
+ <t-radio value="2">入库</t-radio>
|
|
|
|
+ </t-radio-group>
|
|
|
|
+ </t-form-item>
|
|
|
|
+ </t-col>
|
|
|
|
+ <t-col :span="6">
|
|
|
|
+ <t-form-item label="设备出入库时间">
|
|
|
|
+ <t-date-picker v-model="formData.b" style="width: 100%" />
|
|
|
|
+ </t-form-item>
|
|
|
|
+ </t-col>
|
|
|
|
+ <t-col :span="12">
|
|
|
|
+ <t-form-item label="设备出入库登记">
|
|
|
|
+ <div class="w-full">
|
|
|
|
+ <t-table
|
|
|
|
+ class="dynamic-table"
|
|
|
|
+ ref="tableRef"
|
|
|
|
+ row-key="key"
|
|
|
|
+ :columns="columns"
|
|
|
|
+ :data="tableData"
|
|
|
|
+ bordered
|
|
|
|
+ size="small"
|
|
|
|
+ >
|
|
|
|
+ <template #key="{ row }">
|
|
|
|
+ <div class="flex items-center key-cell">
|
|
|
|
+ <Icon
|
|
|
|
+ name="delete"
|
|
|
|
+ class="delete-icon"
|
|
|
|
+ @click="deleteRow(row)"
|
|
|
|
+ ></Icon>
|
|
|
|
+ <span class="key-index">{{ row.key }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <template #a="{ row }">
|
|
|
|
+ <t-select v-model="row.a">
|
|
|
|
+ <t-option value="1">111</t-option>
|
|
|
|
+ <t-option value="2">222</t-option>
|
|
|
|
+ </t-select>
|
|
|
|
+ </template>
|
|
|
|
+ <template #d="{ row }">
|
|
|
|
+ <span v-if="formData.a == '1'">{{ row.d }}</span>
|
|
|
|
+ <t-input v-model="row.d" v-else></t-input>
|
|
|
|
+ </template>
|
|
|
|
+ <template #e="{ row }">
|
|
|
|
+ <span v-if="formData.a == '1'">{{ row.e }}</span>
|
|
|
|
+ <t-input v-model="row.e" v-else></t-input>
|
|
|
|
+ </template>
|
|
|
|
+ <template #f="{ row }">
|
|
|
|
+ <t-input v-model="row.f" v-if="formData.a == '1'"></t-input>
|
|
|
|
+ <span v-else>{{ row.f }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </t-table>
|
|
|
|
+ <t-button theme="primary" class="m-t-15px" @click="createOneRow">
|
|
|
|
+ <template #icon><Icon name="add"></Icon></template>
|
|
|
|
+ 添加
|
|
|
|
+ </t-button>
|
|
|
|
+ </div>
|
|
|
|
+ </t-form-item>
|
|
|
|
+ </t-col>
|
|
|
|
+ </t-row>
|
|
|
|
+ </t-form>
|
|
|
|
+ <template #foot>
|
|
|
|
+ <t-button theme="default" @click="emit('update:visible', false)"
|
|
|
|
+ >取消</t-button
|
|
|
|
+ >
|
|
|
|
+ <t-button theme="primary" @click="save">保存</t-button>
|
|
|
|
+ </template>
|
|
|
|
+ </my-dialog>
|
|
|
|
+</template>
|
|
|
|
+<script setup name="AddDeviceDialog">
|
|
|
|
+import { ref, watch } from 'vue';
|
|
|
|
+import { cloneDeep } from 'lodash';
|
|
|
|
+import { Icon } from 'tdesign-icons-vue-next';
|
|
|
|
+const emit = defineEmits(['update:visible', 'success']);
|
|
|
|
+const formRef = ref(null);
|
|
|
|
+
|
|
|
|
+const props = defineProps({
|
|
|
|
+ visible: Boolean,
|
|
|
|
+});
|
|
|
|
+let data = {
|
|
|
|
+ a: '1',
|
|
|
|
+ b: 2,
|
|
|
|
+ c: [],
|
|
|
|
+};
|
|
|
|
+const formData = ref(cloneDeep(data));
|
|
|
|
+watch(
|
|
|
|
+ () => props.visible,
|
|
|
|
+ () => {
|
|
|
|
+ formData.value = cloneDeep(data);
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
+
|
|
|
|
+const columns = [
|
|
|
|
+ {
|
|
|
|
+ title: '',
|
|
|
|
+ coleKey: 'key',
|
|
|
|
+ cell: 'key',
|
|
|
|
+ align: 'left',
|
|
|
|
+ width: 80,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '设备编号',
|
|
|
|
+ colKey: 'a',
|
|
|
|
+ width: 150,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '供应商',
|
|
|
|
+ colKey: 'b',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '运行状态',
|
|
|
|
+ colKey: 'c',
|
|
|
|
+ width: 80,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '总扫描量',
|
|
|
|
+ colKey: 'd',
|
|
|
|
+ width: 80,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '当前所在地',
|
|
|
|
+ colKey: 'e',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '发往地',
|
|
|
|
+ colKey: 'f',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '快递单拍照',
|
|
|
|
+ colKey: 'g',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+];
|
|
|
|
+const tableData = ref([]);
|
|
|
|
+const resetKeys = () => {
|
|
|
|
+ tableData.value.forEach((item, index) => {
|
|
|
|
+ item.key = index + 1 + '';
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const createOneRow = () => {
|
|
|
|
+ tableData.value.push({ a: '', b: '', c: '', d: '', e: '', f: '', g: '' });
|
|
|
|
+ resetKeys();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+createOneRow();
|
|
|
|
+const deleteRow = (row) => {
|
|
|
|
+ let index = tableData.value.findIndex((item) => item.key == row.key);
|
|
|
|
+ tableData.value.splice(index, 1);
|
|
|
|
+ resetKeys();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const save = () => {
|
|
|
|
+ //ajax...
|
|
|
|
+ emit('success');
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+.dynamic-table {
|
|
|
|
+ width: 100%;
|
|
|
|
+ margin-bottom: 15px;
|
|
|
|
+ .key-cell {
|
|
|
|
+ .key-index {
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ }
|
|
|
|
+ .delete-icon {
|
|
|
|
+ font-size: 18px;
|
|
|
|
+ color: #777;
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ &:hover {
|
|
|
|
+ color: var(--td-brand-color);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|