123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <div v-if="visible" class="forecast-form-container">
- <!-- 销售预测表单容器 - AvueJS版本 -->
- <div class="forecast-form-container basic-container">
- <!-- 表单内容区域 -->
- <div class="forecast-form-content">
- <avue-form
- ref="forecastForm"
- v-model="formData"
- :option="formOption"
- @submit="handleSubmit"
- @reset-change="handleReset"
- >
- <!-- 客户选择器插槽 -->
- <template #customerId>
- <customer-select
- v-model="formData.customerId"
- placeholder="请选择客户"
- @customer-selected="handleCustomerSelected"
- />
- </template>
- <!-- 预测年份插槽(使用 $refs.yearPicker 控制禁用) -->
- <template #year>
- <el-date-picker
- ref="yearPicker"
- v-model="formData.year"
- type="year"
- value-format="yyyy"
- placeholder="请选择年份"
- style="width: 100%"
- />
- </template>
- <!-- 预测月份插槽(使用 $refs.monthSelect 控制禁用) -->
- <template #month="{ column }">
- <el-select
- ref="monthSelect"
- v-model="formData.month"
- placeholder="请选择月份"
- style="width: 100%"
- >
- <el-option
- v-for="opt in (column && column.dicData) ? column.dicData : []"
- :key="opt.value"
- :label="opt.label"
- :value="opt.value"
- />
- </el-select>
- </template>
- </avue-form>
- <!-- 物料表格区域 -->
- <div class="forecast-goods-table">
- <div class="table-title">物料列表</div>
- <!-- 选择并导入物料工具栏 -->
- <div class="table-toolbar">
- <el-select
- v-model="selectedStockId"
- filterable
- clearable
- :disabled="stockSelectOptions.length === 0"
- placeholder="物料名称"
- style="width: 360px"
- >
- <el-option
- v-for="opt in stockSelectOptions"
- :key="opt.value"
- :label="opt.label"
- :value="opt.value"
- />
- </el-select>
- <el-button
- type="primary"
- :disabled="!selectedStockId"
- style="margin-left: 8px"
- @click="handleImportSelectedStock"
- >添加物料</el-button>
- </div>
- <el-table
- :data="stockTableData"
- border
- stripe
- height="360"
- v-loading="tableLoading"
- >
- <el-table-column prop="code" label="物料编码" min-width="140" show-overflow-tooltip />
- <el-table-column prop="cname" label="物料名称" min-width="160" show-overflow-tooltip />
- <el-table-column prop="brandName" label="品牌名称" min-width="120" show-overflow-tooltip />
- <el-table-column prop="typeNo" label="规格" min-width="120" show-overflow-tooltip />
- <el-table-column prop="storeInventory" label="库存数量" min-width="120">
- <template #default="{ row }">
- <span>{{ parseInt(row.storeInventory || 0) }}</span>
- </template>
- </el-table-column>
- <!-- Removed specs/description column: productDescription -->
- <el-table-column label="预测数量" min-width="140">
- <template #default="{ row }">
- <el-input-number
- v-model="row.forecastQuantity"
- :min="0"
- :max="999999"
- :step="1"
- controls-position="right"
- style="width: 120px"
- />
- </template>
- </el-table-column>
- <!-- 操作列:删除按钮 -->
- <el-table-column label="操作" fixed="right" width="120">
- <template #default="{ row, $index }">
- <el-button
- type="text"
- size="small"
- icon="el-icon-delete"
- @click="handleDelete(row, $index)"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="table-tip">提示:先在上方选择物料并点击“导入物料”,导入后的数据将显示在表格并参与保存流程。</div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import forecastFormMixin from './forecast-form-mixin.js'
- import CustomerSelect from '@/components/common/customer-select.vue'
- /**
- * 销售预测表单组件实例类型定义
- * @typedef {object} ForecastFormAvueComponent
- * @property {import('./types').ForecastFormModel} formData - 表单数据
- * @property {import('./types').FormOption} formOption - 表单配置选项
- * @property {boolean} saveLoading - 保存加载状态
- * @property {import('./types').CustomerOption[]} customerOptions - 客户选项列表
- * @property {number|null} currentInventory - 当前库存数量
- * @property {import('./types').ApprovalStatusOption[]} approvalStatusOptions - 审批状态选项
- * @property {import('./types').ForecastFormRules} formRules - 表单验证规则
- * @property {boolean} visible - 表单可见性
- * @property {boolean} isEdit - 是否为编辑模式
- * @property {Object|null} editData - 编辑数据
- * @property {Object|null} initialFormData - 初始表单数据
- * @property {string} title - 表单标题
- * @property {string} forecastId - 预测ID
- */
- /**
- * 销售预测表单组件 - AvueJS版本
- * @description 基于AvueJS的销售预测表单组件,支持新增和编辑销售预测功能
- */
- export default {
- name: 'ForecastFormAvue',
- mixins: [forecastFormMixin],
- /**
- * 组件注册
- */
- components: {
- CustomerSelect
- },
- /**
- * @this {import('./types').ForecastFormMixinComponent & Vue}
- */
- mounted() {
- // 在编辑态,初始禁用“年份/月份”两个控件(通过 $refs 设置)
- this.$nextTick(() => {
- try {
- if (this.isEdit) {
- if (this.$refs.yearPicker) this.$refs.yearPicker.disabled = true
- if (this.$refs.monthSelect) this.$refs.monthSelect.disabled = true
- }
- } catch (e) {
- // 忽略可能的非关键性异常
- }
- })
- },
- methods: {
- // 通过 $refs 统一设置“年份/月份”的禁用状态
- setYearMonthDisabled(disabled) {
- this.$nextTick(() => {
- try {
- if (this.$refs.yearPicker) this.$refs.yearPicker.disabled = disabled
- if (this.$refs.monthSelect) this.$refs.monthSelect.disabled = disabled
- } catch (e) {
- // 忽略可能的非关键性异常
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import './index.scss';
- .forecast-goods-table {
- margin-top: 12px;
- }
- .table-title {
- font-size: 14px;
- color: #333;
- margin-bottom: 8px;
- }
- .table-toolbar {
- margin-bottom: 8px;
- }
- .table-tip {
- margin-top: 8px;
- font-size: 12px;
- color: #909399;
- }
- </style>
|