no message
							parent
							
								
									7b4bb0b05d
								
							
						
					
					
						commit
						d7e2542a00
					
				| 
						 | 
					@ -112,7 +112,6 @@ function changeAreaSelect(selectValue: any) {
 | 
				
			||||||
  if(selectValue){
 | 
					  if(selectValue){
 | 
				
			||||||
    form.areaId = selectValue.areaId;
 | 
					    form.areaId = selectValue.areaId;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 点击确定,验证表单
 | 
					// 点击确定,验证表单
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -345,7 +345,6 @@ function changeLocationSelect(selectValue: any) {
 | 
				
			||||||
  if (selectValue) {
 | 
					  if (selectValue) {
 | 
				
			||||||
    queryForm.locationId = selectValue.locationId;
 | 
					    queryForm.locationId = selectValue.locationId;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,41 +7,39 @@
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <a-modal
 | 
					  <a-modal
 | 
				
			||||||
      :title="form.stockId ? '编辑' : '添加'"
 | 
					      :title="form.stockId ? '编辑容器' : '添加容器'"
 | 
				
			||||||
      :width="600"
 | 
					      :width="600"
 | 
				
			||||||
      :open="visibleFlag"
 | 
					      :open="visibleFlag"
 | 
				
			||||||
      @cancel="onClose"
 | 
					      @cancel="onClose"
 | 
				
			||||||
      :maskClosable="false"
 | 
					      :maskClosable="false"
 | 
				
			||||||
      :destroyOnClose="true"
 | 
					      :destroyOnClose="true"
 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
    <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
 | 
					    <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }">
 | 
				
			||||||
        <a-form-item label="容器id"  name="stockId">
 | 
					
 | 
				
			||||||
          <a-input-number style="width: 100%" v-model:value="form.stockId" placeholder="容器id" />
 | 
					 | 
				
			||||||
        </a-form-item>
 | 
					 | 
				
			||||||
      <a-form-item label="容器编码" name="stockCode">
 | 
					      <a-form-item label="容器编码" name="stockCode">
 | 
				
			||||||
          <a-input style="width: 100%" v-model:value="form.stockCode" placeholder="容器编码" />
 | 
					        <a-input style="width: 100%" v-model:value="form.stockCode" placeholder="容器编码"/>
 | 
				
			||||||
 | 
					      </a-form-item>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      <a-form-item label="类型" name="stockType">
 | 
				
			||||||
 | 
					        <DictSelect width="100%" key-code="STOCK_TYPE" v-model:value="form.stockType"/>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
      <a-form-item label="状态" name="status">
 | 
					      <a-form-item label="状态" name="status">
 | 
				
			||||||
          <SmartEnumSelect width="100%" v-model:value="form.status" enumName="" placeholder="状态"/>
 | 
					        <SmartEnumSelect style="width: 100%" enum-name="USAGE_STATUS_ENUM" v-model:value="form.status"/>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
        <a-form-item label="启用状态"  name="disabledFlag">
 | 
					
 | 
				
			||||||
          <BooleanSelect v-model:value="form.disabledFlag" style="width: 100%" />
 | 
					      <a-form-item label="库位" name="locationId" v-show="form.stockId" >
 | 
				
			||||||
 | 
					        <LocationSelect style="width: 100%" v-model:value="form.locationId" :disabled-flag="true" @change="changeLocationSelect"/>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
        <a-form-item label="容器类型"  name="stockType">
 | 
					
 | 
				
			||||||
          <DictSelect width="100%" v-model:value="form.stockType" keyCode="STOCK_TYPE" placeholder="容器类型"/>
 | 
					      <a-form-item label="是否启用" name="disabledFlag">
 | 
				
			||||||
        </a-form-item>
 | 
					        <a-switch
 | 
				
			||||||
        <a-form-item label="创建人ID"  name="createUserId">
 | 
					            v-model:checked="form.disabledFlag"
 | 
				
			||||||
          <a-input-number style="width: 100%" v-model:value="form.createUserId" placeholder="创建人ID" />
 | 
					            checked-children="启用"
 | 
				
			||||||
        </a-form-item>
 | 
					            un-checked-children="禁用"
 | 
				
			||||||
        <a-form-item label="创建人"  name="createUserName">
 | 
					        />
 | 
				
			||||||
          <a-input style="width: 100%" v-model:value="form.createUserName" placeholder="创建人" />
 | 
					 | 
				
			||||||
        </a-form-item>
 | 
					 | 
				
			||||||
        <a-form-item label="创建时间"  name="createTime">
 | 
					 | 
				
			||||||
          <a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.createTime" style="width: 100%" placeholder="创建时间" />
 | 
					 | 
				
			||||||
        </a-form-item>
 | 
					 | 
				
			||||||
        <a-form-item label="更新时间"  name="updateTime">
 | 
					 | 
				
			||||||
          <a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.updateTime" style="width: 100%" placeholder="更新时间" />
 | 
					 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </a-form>
 | 
					    </a-form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <template #footer>
 | 
					    <template #footer>
 | 
				
			||||||
| 
						 | 
					@ -53,89 +51,87 @@
 | 
				
			||||||
  </a-modal>
 | 
					  </a-modal>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
<script setup lang="ts">
 | 
					<script setup lang="ts">
 | 
				
			||||||
  import { reactive, ref, nextTick } from 'vue';
 | 
					import {reactive, ref, nextTick} from 'vue';
 | 
				
			||||||
  import _ from 'lodash';
 | 
					import _ from 'lodash';
 | 
				
			||||||
  import { message } from 'ant-design-vue';
 | 
					import {message} from 'ant-design-vue';
 | 
				
			||||||
  import { SmartLoading } from '/@/components/framework/smart-loading';
 | 
					import {SmartLoading} from '/@/components/framework/smart-loading';
 | 
				
			||||||
  import { stockApi } from '/@/api/business/base/stock/stock-api';
 | 
					import {stockApi} from '/@/api/business/base/stock/stock-api';
 | 
				
			||||||
  import { smartSentry } from '/@/lib/smart-sentry';
 | 
					import {smartSentry} from '/@/lib/smart-sentry';
 | 
				
			||||||
  import BooleanSelect from '/@/components/framework/boolean-select/index.vue';
 | 
					import DictSelect from '/@/components/support/dict-select/index.vue';
 | 
				
			||||||
  import DictSelect from '/@/components/support/dict-select/index.vue';
 | 
					import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
 | 
				
			||||||
  import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
 | 
					import {USAGE_STATUS_ENUM} from "/@/constants/business/base/usagestatus-const";
 | 
				
			||||||
 | 
					import LocationSelect from "/@/views/business/base/location/location-select.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // ------------------------ 事件 ------------------------
 | 
					//选择库区
 | 
				
			||||||
 | 
					function changeLocationSelect(selectValue: any) {
 | 
				
			||||||
 | 
					  if(selectValue){
 | 
				
			||||||
 | 
					    form.locationId = selectValue.locationId;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const emits = defineEmits(['reloadList']);
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // ------------------------ 显示与隐藏 ------------------------
 | 
					// ------------------------ 事件 ------------------------
 | 
				
			||||||
  // 是否显示
 | 
					 | 
				
			||||||
  const visibleFlag = ref(false);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function show(rowData:object) {
 | 
					const emits = defineEmits(['reloadList']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------ 显示与隐藏 ------------------------
 | 
				
			||||||
 | 
					// 是否显示
 | 
				
			||||||
 | 
					const visibleFlag = ref(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function show(rowData: object) {
 | 
				
			||||||
  Object.assign(form, formDefault);
 | 
					  Object.assign(form, formDefault);
 | 
				
			||||||
  if (rowData && !_.isEmpty(rowData)) {
 | 
					  if (rowData && !_.isEmpty(rowData)) {
 | 
				
			||||||
    Object.assign(form, rowData);
 | 
					    Object.assign(form, rowData);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
    // 使用字典时把下面这注释修改成自己的字典字段 有多个字典字段就复制多份同理修改 不然打开表单时不显示字典初始值
 | 
					 | 
				
			||||||
    // if (form.status && form.status.length > 0) {
 | 
					 | 
				
			||||||
    //   form.status = form.status.map((e) => e.valueCode);
 | 
					 | 
				
			||||||
    // }
 | 
					 | 
				
			||||||
  visibleFlag.value = true;
 | 
					  visibleFlag.value = true;
 | 
				
			||||||
  nextTick(() => {
 | 
					  nextTick(() => {
 | 
				
			||||||
    formRef.value.clearValidate();
 | 
					    formRef.value.clearValidate();
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function onClose() {
 | 
					function onClose() {
 | 
				
			||||||
  Object.assign(form, formDefault);
 | 
					  Object.assign(form, formDefault);
 | 
				
			||||||
  visibleFlag.value = false;
 | 
					  visibleFlag.value = false;
 | 
				
			||||||
  }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // ------------------------ 表单 ------------------------
 | 
					// ------------------------ 表单 ------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 组件ref
 | 
					// 组件ref
 | 
				
			||||||
  const formRef = ref();
 | 
					const formRef = ref();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const formDefault = {
 | 
					const formDefault = {
 | 
				
			||||||
  stockId: undefined, //容器id
 | 
					  stockId: undefined, //容器id
 | 
				
			||||||
  stockCode: undefined, //容器编码
 | 
					  stockCode: undefined, //容器编码
 | 
				
			||||||
      status: undefined, //状态
 | 
					  status: USAGE_STATUS_ENUM.FREE.value, //状态
 | 
				
			||||||
      disabledFlag: undefined, //启用状态
 | 
					  disabledFlag: true, //是否禁用
 | 
				
			||||||
      stockType: undefined, //容器类型
 | 
					  stockType: [], //容器类型
 | 
				
			||||||
      createUserId: undefined, //创建人ID
 | 
					  locationId: undefined,//库位
 | 
				
			||||||
      createUserName: undefined, //创建人
 | 
					};
 | 
				
			||||||
      createTime: undefined, //创建时间
 | 
					 | 
				
			||||||
      updateTime: undefined, //更新时间
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let form = reactive({ ...formDefault });
 | 
					let form = reactive({...formDefault});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const rules = {
 | 
					const rules = {
 | 
				
			||||||
      stockId: [{ required: true, message: '容器id 必填' }],
 | 
					  stockCode: [{required: true, message: '容器编码 必填'}],
 | 
				
			||||||
      stockCode: [{ required: true, message: '容器编码 必填' }],
 | 
					  status: [{required: true, message: '状态 必填'}],
 | 
				
			||||||
      status: [{ required: true, message: '状态 必填' }],
 | 
					  disabledFlag: [{required: true, message: '启用状态 必填'}],
 | 
				
			||||||
      disabledFlag: [{ required: true, message: '启用状态 必填' }],
 | 
					  stockType: [{required: true, message: '容器类型 必填'}],
 | 
				
			||||||
      stockType: [{ required: true, message: '容器类型 必填' }],
 | 
					};
 | 
				
			||||||
      createUserId: [{ required: true, message: '创建人ID 必填' }],
 | 
					 | 
				
			||||||
      createUserName: [{ required: true, message: '创建人 必填' }],
 | 
					 | 
				
			||||||
      createTime: [{ required: true, message: '创建时间 必填' }],
 | 
					 | 
				
			||||||
      updateTime: [{ required: true, message: '更新时间 必填' }],
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 点击确定,验证表单
 | 
					// 点击确定,验证表单
 | 
				
			||||||
  async function onSubmit() {
 | 
					async function onSubmit() {
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    await formRef.value.validateFields();
 | 
					    await formRef.value.validateFields();
 | 
				
			||||||
      save();
 | 
					    await save();
 | 
				
			||||||
  } catch (err) {
 | 
					  } catch (err) {
 | 
				
			||||||
    message.error('参数验证错误,请仔细填写表单数据!');
 | 
					    message.error('参数验证错误,请仔细填写表单数据!');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 新建、编辑API
 | 
					// 新建、编辑API
 | 
				
			||||||
  async function save() {
 | 
					async function save() {
 | 
				
			||||||
  SmartLoading.show();
 | 
					  SmartLoading.show();
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
 | 
					    console.log(form)
 | 
				
			||||||
    if (form.stockId) {
 | 
					    if (form.stockId) {
 | 
				
			||||||
      await stockApi.update(form);
 | 
					      await stockApi.update(form);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
| 
						 | 
					@ -149,9 +145,9 @@
 | 
				
			||||||
  } finally {
 | 
					  } finally {
 | 
				
			||||||
    SmartLoading.hide();
 | 
					    SmartLoading.hide();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  defineExpose({
 | 
					defineExpose({
 | 
				
			||||||
  show,
 | 
					  show,
 | 
				
			||||||
  });
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,8 +9,20 @@
 | 
				
			||||||
  <!---------- 查询表单form begin ----------->
 | 
					  <!---------- 查询表单form begin ----------->
 | 
				
			||||||
  <a-form class="smart-query-form">
 | 
					  <a-form class="smart-query-form">
 | 
				
			||||||
    <a-row class="smart-query-form-row">
 | 
					    <a-row class="smart-query-form-row">
 | 
				
			||||||
      <a-form-item label="容器编码" class="smart-query-form-item">
 | 
					      <a-form-item label="容器" class="smart-query-form-item">
 | 
				
			||||||
        <a-input style="width: 200px" v-model:value="queryForm.stockCode" placeholder="容器编码"/>
 | 
					        <StockSelect v-model:value="queryForm.stockId" :disabled-flag="true" @change="changeStockSelect"/>
 | 
				
			||||||
 | 
					      </a-form-item>
 | 
				
			||||||
 | 
					      <a-form-item label="库位" class="smart-query-form-item">
 | 
				
			||||||
 | 
					        <LocationSelect v-model:value="queryForm.locationId" :disabledFlag="true" @change="changeLocationSelect"/>
 | 
				
			||||||
 | 
					      </a-form-item>
 | 
				
			||||||
 | 
					      <a-form-item label="状态" class="smart-query-form-item">
 | 
				
			||||||
 | 
					        <SmartEnumSelect style="width: 200px" enum-name="USAGE_STATUS_ENUM" v-model:value="queryForm.status"/>
 | 
				
			||||||
 | 
					      </a-form-item>
 | 
				
			||||||
 | 
					      <a-form-item label="是否启用" class="smart-query-form-item">
 | 
				
			||||||
 | 
					        <a-select style="width: 200px" v-model:value="queryForm.disabledFlag" allowClear placeholder="请选择">
 | 
				
			||||||
 | 
					          <a-select-option :value="true">启用</a-select-option>
 | 
				
			||||||
 | 
					          <a-select-option :value="false">禁用</a-select-option>
 | 
				
			||||||
 | 
					        </a-select>
 | 
				
			||||||
      </a-form-item>
 | 
					      </a-form-item>
 | 
				
			||||||
      <a-form-item class="smart-query-form-item">
 | 
					      <a-form-item class="smart-query-form-item">
 | 
				
			||||||
        <a-button type="primary" @click="onSearch" class="smart-margin-left10">
 | 
					        <a-button type="primary" @click="onSearch" class="smart-margin-left10">
 | 
				
			||||||
| 
						 | 
					@ -177,10 +189,13 @@ import {smartSentry} from '/@/lib/smart-sentry';
 | 
				
			||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
 | 
					import TableOperator from '/@/components/support/table-operator/index.vue';
 | 
				
			||||||
import StockForm from '/@/views/business/base/stock/stock-form.vue';
 | 
					import StockForm from '/@/views/business/base/stock/stock-form.vue';
 | 
				
			||||||
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
 | 
					import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
 | 
				
			||||||
import DictPreview from "/@/components/dict-preview/index.vue";
 | 
					import DictPreview from '/@/components/dict-preview/index.vue';
 | 
				
			||||||
import {useDict} from "/@/utils/dict";
 | 
					import {useDict} from "/@/utils/dict";
 | 
				
			||||||
import {UploadFile} from 'ant-design-vue';
 | 
					import {UploadFile} from 'ant-design-vue';
 | 
				
			||||||
import {fileApi} from "/@/api/support/file-api";
 | 
					import {fileApi} from "/@/api/support/file-api";
 | 
				
			||||||
 | 
					import StockSelect from "/@/views/business/base/stock/stock-select.vue";
 | 
				
			||||||
 | 
					import SmartEnumSelect from "/@/components/framework/smart-enum-select/index.vue";
 | 
				
			||||||
 | 
					import LocationSelect from "/@/views/business/base/location/location-select.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//容器类型
 | 
					//容器类型
 | 
				
			||||||
| 
						 | 
					@ -235,7 +250,10 @@ const columns = ref([
 | 
				
			||||||
// ---------------------------- 查询数据表单和方法 ----------------------------
 | 
					// ---------------------------- 查询数据表单和方法 ----------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const queryFormState = {
 | 
					const queryFormState = {
 | 
				
			||||||
  stockCode: undefined, //容器编码
 | 
					  stockId: undefined, //容器
 | 
				
			||||||
 | 
					  locationId: undefined,//库位
 | 
				
			||||||
 | 
					  disabledFlag: undefined,//是否启用
 | 
				
			||||||
 | 
					  status: undefined,//状态
 | 
				
			||||||
  pageNum: 1,
 | 
					  pageNum: 1,
 | 
				
			||||||
  pageSize: 10,
 | 
					  pageSize: 10,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -262,6 +280,20 @@ function onSearch() {
 | 
				
			||||||
  queryData();
 | 
					  queryData();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//选择容器
 | 
				
			||||||
 | 
					function changeStockSelect(selectValue: any) {
 | 
				
			||||||
 | 
					  if (selectValue) {
 | 
				
			||||||
 | 
					    queryForm.stockId = selectValue.stockId;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//选择库位
 | 
				
			||||||
 | 
					function changeLocationSelect(selectValue: any) {
 | 
				
			||||||
 | 
					  if (selectValue) {
 | 
				
			||||||
 | 
					    queryForm.locationId = selectValue.locationId;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 查询数据
 | 
					// 查询数据
 | 
				
			||||||
async function queryData() {
 | 
					async function queryData() {
 | 
				
			||||||
  tableLoading.value = true;
 | 
					  tableLoading.value = true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,110 @@
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					  * 容器 下拉选择框
 | 
				
			||||||
 | 
					  *
 | 
				
			||||||
 | 
					  *
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <a-select
 | 
				
			||||||
 | 
					      v-model:value="selectValue"
 | 
				
			||||||
 | 
					      :style="`width: ${width}`"
 | 
				
			||||||
 | 
					      :placeholder="props.placeholder"
 | 
				
			||||||
 | 
					      :showSearch="true"
 | 
				
			||||||
 | 
					      :allowClear="true"
 | 
				
			||||||
 | 
					      :size="size"
 | 
				
			||||||
 | 
					      @change="handleChange"
 | 
				
			||||||
 | 
					      :disabled="disabled"
 | 
				
			||||||
 | 
					      :mode="multiple ? 'multiple' : ''"
 | 
				
			||||||
 | 
					      optionFilterProp="label"
 | 
				
			||||||
 | 
					  >
 | 
				
			||||||
 | 
					    <a-select-option v-for="stock in stocks" :key="stock.stockId" :label="stock.stockCode">
 | 
				
			||||||
 | 
					      {{ stock.stockCode }}
 | 
				
			||||||
 | 
					      <div style="float: right">
 | 
				
			||||||
 | 
					        <template v-if="stock.stockType">
 | 
				
			||||||
 | 
					          <DictPreview :options="stockType.STOCK_TYPE" :value="stock.stockType"/>
 | 
				
			||||||
 | 
					        </template>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					    </a-select-option>
 | 
				
			||||||
 | 
					  </a-select>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script setup lang="ts">
 | 
				
			||||||
 | 
					import {onMounted, ref, watch} from 'vue';
 | 
				
			||||||
 | 
					import {stockApi} from "/@/api/business/base/stock/stock-api";
 | 
				
			||||||
 | 
					import {useDict} from "/@/utils/dict";
 | 
				
			||||||
 | 
					import DictPreview from "/@/components/dict-preview/index.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//容器类型
 | 
				
			||||||
 | 
					const stockType = useDict('STOCK_TYPE');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = defineProps({
 | 
				
			||||||
 | 
					  value: [Number, String, Object, Array],
 | 
				
			||||||
 | 
					  width: {
 | 
				
			||||||
 | 
					    type: String,
 | 
				
			||||||
 | 
					    default: '200px',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  placeholder: {
 | 
				
			||||||
 | 
					    type: String,
 | 
				
			||||||
 | 
					    default: '请选择',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  size: {
 | 
				
			||||||
 | 
					    type: String,
 | 
				
			||||||
 | 
					    default: 'default',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  disabled: {
 | 
				
			||||||
 | 
					    type: Boolean,
 | 
				
			||||||
 | 
					    default: false,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  multiple: {
 | 
				
			||||||
 | 
					    type: Boolean,
 | 
				
			||||||
 | 
					    default: false,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  status: {
 | 
				
			||||||
 | 
					    type: String,
 | 
				
			||||||
 | 
					    default: null,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  disabledFlag: {
 | 
				
			||||||
 | 
					    type: Boolean,
 | 
				
			||||||
 | 
					    default: null,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const stocks = ref([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function queryData() {
 | 
				
			||||||
 | 
					  let res = await stockApi.queryStock({
 | 
				
			||||||
 | 
					    status: props.status,
 | 
				
			||||||
 | 
					    disabledFlag: props.disabledFlag
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					  stocks.value = res.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const emit = defineEmits(['update:value', 'change']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const selectValue = ref(props.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 箭头value变化
 | 
				
			||||||
 | 
					watch(
 | 
				
			||||||
 | 
					    () => props.value,
 | 
				
			||||||
 | 
					    (newValue) => {
 | 
				
			||||||
 | 
					      selectValue.value = newValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleChange(value: any) {
 | 
				
			||||||
 | 
					  let selectedStocks: any[] | any;
 | 
				
			||||||
 | 
					  if (Array.isArray(value)) {
 | 
				
			||||||
 | 
					    // 多选情况
 | 
				
			||||||
 | 
					    selectedStocks = value.map((id) => stocks.value.find((item: any) => item.stockId === id)).filter(Boolean);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    // 单选情况
 | 
				
			||||||
 | 
					    selectedStocks = stocks.value.find((item: any) => item.stockId === value);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  emit('update:value', value);
 | 
				
			||||||
 | 
					  emit('change', selectedStocks);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					onMounted(queryData);
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue