123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <!-- 物料明细表格容器 -->
- <div class="material-detail-container">
- <!-- 表格头部操作区域 -->
- <div class="material-detail-header">
- <div class="header-left">
- <span class="section-title">物料明细</span>
- <el-tag
- v-if="materialDetails.length > 0"
- type="info"
- size="small"
- class="count-tag"
- >
- 共 {{ materialDetails.length }} 条
- </el-tag>
- </div>
- <div class="header-right">
- <!-- 物料选择区域 -->
- <div class="material-select-container">
- <el-select
- v-model="selectedMaterialId"
- placeholder="请选择物料"
- filterable
- remote
- reserve-keyword
- :remote-method="remoteSearchMaterial"
- :loading="materialLoading"
- size="small"
- style="width: 300px; margin-right: 8px;"
- clearable
- >
- <el-option
- v-for="item in materialOptions"
- :key="item.id"
- :label="`${item.itemName} (${item.itemCode})`"
- :value="item.id"
- >
- <span style="float: left">{{ item.itemName }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.itemCode }}</span>
- </el-option>
- </el-select>
- <el-button
- type="primary"
- icon="el-icon-plus"
- size="small"
- :disabled="!selectedMaterialId"
- @click="handleImportSelectedMaterial"
- >
- 增加
- </el-button>
- <el-button
- v-if="editMode && selectedRows.length > 0"
- type="danger"
- icon="el-icon-delete"
- size="small"
- @click="handleBatchDelete"
- >
- 批量删除 ({{ selectedRows.length }})
- </el-button>
- </div>
- </div>
- </div>
- <!-- 物料明细表格 -->
- <div class="material-detail-content">
- <avue-crud
- ref="materialDetailCrud"
- :data="currentPageData"
- :option="tableOption"
- :page.sync="page"
- @refresh-change="handleRefresh"
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange"
- @selection-change="handleSelectionChange"
- @row-del="handleRowDelete"
- @row-update="handleRowUpdate"
- >
- <!-- 可用数量自定义模板 -->
- <template slot="availableQuantity" slot-scope="scope">
- <span>{{ formatFloatNumber(scope.row.availableQuantity) }}</span>
- </template>
- <!-- 确认数量自定义模板 -->
- <template slot="confirmQuantity" slot-scope="scope">
- <span>{{ formatFloatNumber(scope.row.confirmQuantity) }}</span>
- </template>
- <!-- 单价自定义模板 -->
- <template slot="unitPrice" slot-scope="scope">
- <el-input
- v-if="editMode && isRowEditable(scope.row)"
- v-model="scope.row.unitPrice"
- size="mini"
- style="width: 100%"
- placeholder="请输入单价"
- :disabled="true"
- @input="validateFloatInput($event, scope.row, 'unitPrice')"
- @blur="handleUnitPriceBlur(scope.row, scope.$index)"
- />
- <span v-else>{{ formatUnitPrice(scope.row.unitPrice) }}</span>
- </template>
- <!-- 订单数量自定义模板 -->
- <template slot="orderQuantity" slot-scope="scope">
- <el-input
- v-if="editMode && isRowEditable(scope.row)"
- v-model="scope.row.orderQuantity"
- size="mini"
- style="width: 100%"
- placeholder="请输入订单数量"
- @input="validateIntegerInput($event, scope.row, 'orderQuantity')"
- @blur="handleQuantityBlur(scope.row, scope.$index)"
- />
- <span v-else>{{ formatIntegerNumber(scope.row.orderQuantity) }}</span>
- </template>
- <!-- 税率自定义模板 -->
- <template slot="taxRate" slot-scope="scope">
- <el-input
- v-if="editMode && isRowEditable(scope.row)"
- v-model="scope.row.taxRate"
- size="mini"
- style="width: 100%"
- placeholder="请输入税率"
- :disabled="true"
- @input="validateFloatInput($event, scope.row, 'taxRate', 0, 100)"
- @blur="validateAndFormatFloatOnBlur(scope.row, 'taxRate', 0, 100); handleTaxRateChange(scope.row, scope.$index)"
- />
- <span v-else>{{ formatTaxRate(scope.row.taxRate, false) }}%</span>
- </template>
- <!-- 税额自定义模板 -->
- <template slot="taxAmount" slot-scope="scope">
- <el-input
- v-if="editMode && isRowEditable(scope.row)"
- v-model="scope.row.taxAmount"
- size="mini"
- style="width: 100%"
- placeholder="请输入税额"
- :disabled="true"
- @input="validateFloatInput($event, scope.row, 'taxAmount')"
- @blur="validateAndFormatFloatOnBlur(scope.row, 'taxAmount'); handleTaxAmountChange(scope.row, scope.$index)"
- />
- <span v-else>{{ formatAmount(scope.row.taxAmount, false) }}</span>
- </template>
- <!-- 总金额自定义模板 -->
- <template slot="totalAmount" slot-scope="scope">
- <el-input
- v-if="editMode && isRowEditable(scope.row)"
- v-model="scope.row.totalAmount"
- size="mini"
- style="width: 100%"
- placeholder="请输入总金额"
- :disabled="true"
- @input="validateFloatInput($event, scope.row, 'totalAmount')"
- @blur="validateAndFormatFloatOnBlur(scope.row, 'totalAmount'); handleTotalAmountChange(scope.row, scope.$index)"
- />
- <span v-else>{{ formatAmount(scope.row.totalAmount, false) }}</span>
- </template>
- <!-- 明细状态列自定义渲染 -->
- <template slot="status" slot-scope="{ row }">
- <el-tag
- :type="getStatusTagType(row.itemStatus)"
- size="mini"
- >
- {{ getStatusText(row.itemStatus) }}
- </el-tag>
- </template>
- <!-- 操作列自定义渲染 -->
- <template slot="menu" slot-scope="{ row, index }">
- <el-button
- v-if="row.isDeletable"
- type="text"
- size="mini"
- icon="el-icon-delete"
- class="delete-btn"
- @click="handleDeleteMaterial(row, index)"
- >
- 删除
- </el-button>
- </template>
- </avue-crud>
- </div>
- </div>
- </template>
- <script>
- import materialDetailMixin from './material-detail-mixin';
- export default {
- name: 'MaterialDetailTable',
- mixins: [materialDetailMixin],
- }
- </script>
- <style scoped>
- .material-detail-container {
- padding: 20px;
- }
- .material-detail-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 16px;
- padding-bottom: 12px;
- border-bottom: 1px solid #ebeef5;
- }
- .header-left {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .section-title {
- font-size: 16px;
- font-weight: 600;
- color: #303133;
- }
- .count-tag {
- font-size: 12px;
- }
- .header-right {
- display: flex;
- gap: 8px;
- margin-right: 32px;
- }
- .material-select-container {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- .material-select-container .el-select {
- min-width: 300px;
- }
- .material-select-container .el-button {
- white-space: nowrap;
- }
- .material-detail-content {
- background-color: #ffffff;
- border-radius: 4px;
- }
- .delete-btn {
- color: #f56c6c;
- }
- .delete-btn:hover {
- color: #f78989;
- }
- .amount-text {
- font-weight: 600;
- color: #409eff;
- }
- .dialog-footer {
- text-align: right;
- }
- /* 响应式设计 */
- @media (max-width: 768px) {
- .material-detail-container {
- padding: 12px;
- }
- .material-detail-header {
- flex-direction: column;
- gap: 12px;
- align-items: flex-start;
- }
- .header-right {
- width: 100%;
- justify-content: flex-end;
- }
- }
- </style>
|