quyx@nextosd.com 5 ヶ月 前
コミット
f92d75d7f4
1 ファイル変更144 行追加162 行削除
  1. 144 162
      src/views/bbib/result/compilation.vue

+ 144 - 162
src/views/bbib/result/compilation.vue

@@ -1,65 +1,60 @@
 <template>
 <template>
   <div class="app-container">
   <div class="app-container">
-    <p>実績ID: {{ orderId }}</p>
+    <p>実績ID: {{ resultId }}</p>
     <p class="order-version">{{ formattedMonthYear }}</p>
     <p class="order-version">{{ formattedMonthYear }}</p>
 
 
    <el-table :row-class-name="tableRowClassName" v-show="initLoadingCompleted" v-loading="listLoading" :border="true" :data="examKindList" class="order-version" :cell-style="cellStyle" >
    <el-table :row-class-name="tableRowClassName" v-show="initLoadingCompleted" v-loading="listLoading" :border="true" :data="examKindList" class="order-version" :cell-style="cellStyle" >
-      <el-table-column align="center" header-align="center" label="線便コード" prop="departureCode" min-width="72">
+      <el-table-column :align="center" header-align="center" label="線便コード" prop="vehicleRouter" min-width="150">
       <template #default="scope">
       <template #default="scope">
-         <template v-if="scope.row.isNewRow">
-           <input v-model="scope.row.departureCode" class="no-border-input" ></input>
-         </template>
-         <template v-else>
-           {{ scope.row.departureCode }} 
-         </template>
+           {{ scope.row.vehicleRouter }} 
        </template>
        </template>
       </el-table-column>
       </el-table-column>
-      <el-table-column align="center" header-align="center" label="線便名" prop="arrivalCode" min-width="72">
+      <el-table-column :align="center" header-align="center" label="線便名" prop="lineName" min-width="100">
       <template #default="scope">
       <template #default="scope">
-         <template v-if="scope.row.isNewRow">
-           <input v-model="scope.row.arrivalCode" class="no-border-input" ></input>
-         </template>
-         <template v-else>
-           {{ scope.row.arrivalCode }} 
-         </template>
+           {{ scope.row.lineName }} 
        </template>
        </template>
       </el-table-column>
       </el-table-column>
 
 
-    <el-table-column align="center" header-align="center" v-for="(num, index) in originalDataLength" :key="index" :label="num"  >
-      <el-table-column align="center" header-align="center" :label="getElement(num)" :prop="'num_' + num" min-width="40" >
+    <el-table-column :align="center" header-align="center" v-for="(num, colIndex) in 31" :key="colIndex" :label="num"  >
+      <el-table-column :align="center" header-align="center" :label="getElement(num)" :prop="'num_' + num" min-width="70" >
         <template #default="scope">
         <template #default="scope">
-          <template v-if="scope.row.isNewRow">
-            <input v-model="scope.row[`num_${num}`]" class="no-border-input" ></input>
-          </template>
-           <template v-else>
              <span 
              <span 
                @click="open(scope.row, num)" 
                @click="open(scope.row, num)" 
                style="display: block; min-height: 24px;"
                style="display: block; min-height: 24px;"
              >
              >
-               {{ getDataByIndex(index) || ' ' }}
+               {{ getValueFromOriginal(scope.$index, colIndex) || ' ' }}
             </span>
             </span>
-           </template>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
     </el-table-column>
     </el-table-column>
+    <el-table-column :align="center" header-align="center" label="日数" min-width="50">
+      <template #default="scope">
+        {{ calculateDays(scope.$index) }} 
+      </template>
+    </el-table-column>
+    <el-table-column :align="center" header-align="center" label="合計" min-width="100">
+      <template #default="scope">
+        {{ calculateTotal(scope.$index) }} 
+      </template>
+    </el-table-column>
   </el-table>
   </el-table>
 
 
     <el-button  class="save-button4" @click="saveChanges">変更を保存</el-button>
     <el-button  class="save-button4" @click="saveChanges">変更を保存</el-button>
-    <el-button  class="discard-button" @click="discardChanges" :disabled="isSaved" >輸送パートナーに送付する</el-button>
-<div class="comment-section">
-    <p class="search-info">状態・アクション履歴</p>
-    <div class="flex-container">
-      <p class="history">履歴</p>
-      <textarea 
-        id="comment" 
-        rows="17" 
-        cols="100" 
-        class="comment-textarea" 
-        v-model="commentText"
-        readonly 
-      />
+    <el-button  class="discard-button" @click="discardChanges" >輸送パートナーに送付する</el-button>
+    <div class="comment-section">
+      <p class="search-info">状態・アクション履歴</p>
+      <div class="flex-container">
+        <p class="history">履歴</p>
+        <textarea 
+            id="comment" 
+            rows="17" 
+            cols="100" 
+            class="comment-textarea" 
+            v-model="commentText"
+            readonly 
+        />
+      </div>
     </div>
     </div>
-  </div>
 
 
 
 
   <div class="flex-container">
   <div class="flex-container">
@@ -70,7 +65,7 @@
   <div>
   <div>
      <el-form-item prop="actionType">
      <el-form-item prop="actionType">
           <el-select v-model="actionForm.actionType" class="select-short">
           <el-select v-model="actionForm.actionType" class="select-short">
-           <el-option v-for="option in reasonOptions" :key="option.value" :label="option.label" :value="option.value" />
+           <el-option v-for="option in actionTypeOptions" :key="option.value" :label="option.label" :value="option.value" />
           </el-select>
           </el-select>
         </el-form-item>
         </el-form-item>
   </div>
   </div>
@@ -92,18 +87,15 @@
         </el-select>
         </el-select>
       </el-form-item>
       </el-form-item>
       <el-form-item label="変更後">
       <el-form-item label="変更後">
-        <el-input v-model="changedValue" @keyup.enter="handleEnter" />
+        <el-input v-model="changedValue" @keyup.enter="handleEnter"  type="number" />
       </el-form-item>
       </el-form-item>
     </el-form>
     </el-form>
     </el-dialog>
     </el-dialog>
   </div>
   </div>
 </template>
 </template>
 
 
-<script name="ExamKind" setup>
-import {formatMsg, parseAlphabetNumeric} from "@/utils/eiken"
-import {delay} from "@/utils/index.js";
-import {encryptField} from "@/utils/encrypt.js";
-import { listOrder, getOrder, delOrder, addOrder, updateOrder,getOrderCompilation } from "@/api/yamato/order"
+<script name="ResultCompilation" setup>
+import { listOrder, getOrder, delOrder, addOrder, updateOrder,getOrderCompilation,listAction } from "@/api/bbib/result"
 import { useRoute } from 'vue-router'
 import { useRoute } from 'vue-router'
 
 
 const {proxy} = getCurrentInstance();
 const {proxy} = getCurrentInstance();
@@ -112,17 +104,14 @@ const router = useRouter()
 const examKindList = ref([]);
 const examKindList = ref([]);
 const initialData = ref([]); // 存储初始数据
 const initialData = ref([]); // 存储初始数据
 const originalDataList = ref([]);
 const originalDataList = ref([]);
-const isSaved = ref(false); 
+const commentText = ref('');
 
 
 const canAddNewRow = ref(true); 
 const canAddNewRow = ref(true); 
 const originalDataLength = ref(0);
 const originalDataLength = ref(0);
+const insertedOrderList = ref([]);
 const route = useRoute()
 const route = useRoute()
-const orderId = route.params.resultId
-const version = ref(Number(route.params.version));
-const newFlag  = Number(route.query.newFlag);
-const versionPlusOne = computed(() => {
-      return version.value + 1;
-    });
+const resultId = route.params.resultId
+const actionKind = 2;
 const formattedMonthYear = computed(() => {
 const formattedMonthYear = computed(() => {
   const monthYear = examKindList.value[0]?.monthYear || '';
   const monthYear = examKindList.value[0]?.monthYear || '';
   if (!monthYear || monthYear.length !== 6) return monthYear;
   if (!monthYear || monthYear.length !== 6) return monthYear;
@@ -131,21 +120,49 @@ const formattedMonthYear = computed(() => {
   return `${monthYear.substring(0, 4)}/${monthYear.substring(4)}`;
   return `${monthYear.substring(0, 4)}/${monthYear.substring(4)}`;
 });
 });
 
 
- const getDataByIndex = computed(() => {
-      return (index) => {
-        return newFlag === 1 
-          ? getNewDataByIndex(index) 
-          : getRunWeekDayByIndex(index);
-      };
-    });
-
-    const actionForm  = ref({
-  actionType: '', // 下拉列表选中值
-  actionComment: '', // 文本框输入值
-  actionCode: orderId // 路由中的orderId
+const getFeeByIndex = computed(() => {
+  return (index) => getCharterFeeByIndex(index);
 });
 });
 
 
 
 
+const actionForm = ref({
+  actionType: '',
+  actionComment: '',
+  actionCode: resultId
+});   
+
+const calculateDays = (rowIndex) => {
+  let count = 0
+  for (let colIndex = 0; colIndex < 31; colIndex++) {
+    const value = getValueFromOriginal(rowIndex, colIndex)
+    if (value && Number(value) !== 0) {
+      count++
+    }
+  }
+  return count
+}
+
+const calculateTotal = (rowIndex) => {
+  let sum = 0
+  for (let colIndex = 0; colIndex < 31; colIndex++) {
+    const value = getValueFromOriginal(rowIndex, colIndex)
+    if (value) {
+      sum += Number(value)
+    }
+  }
+  return sum
+}
+
+
+const getValueFromOriginal = (rowIndex, colIndex) => {
+  const originalIndex = rowIndex * 31 + colIndex;
+  if (originalIndex < originalDataList.value.length) {
+    // 假设要取 charterFee 字段,实际根据需求调整
+    return originalDataList.value[originalIndex]?.charterFee || '';
+  }
+  return '';
+};
+
 const initializeData = (data) => {
 const initializeData = (data) => {
   const dataArray = Array.isArray(data) ? data : [data];
   const dataArray = Array.isArray(data) ? data : [data];
   
   
@@ -163,48 +180,54 @@ const initializeData = (data) => {
   });
   });
 };
 };
 
 
+function getActionList() {
+  listLoading.value = true;
+ const data = { resultId, actionKind };
+  listAction(data).then(response => {
+    insertedOrderList.value = response.data || [];
+    
+    // 格式化每条记录
+    const content = insertedOrderList.value.map(item => {
+      const date = item.actionDate.replace(/-/g, '/');
+      const title = item.actionTitle || '';
+      const comment = item.actionComment || '';
+
+      return `${date}   ${title}\n ${comment}`;
+    }).join('\n\n'); // 每条记录用两个换行分隔
+    
+    commentText.value = content; // 更新文本内容
+    listLoading.value = false;
+    initLoadingCompleted.value = true;
+  });
+}
 
 
 
 
-
-watch(examKindList, () => {
-  checkAddButtonState();
-}, { deep: true });
-
-function checkAddButtonState() {
-  const lastRow = examKindList.value[examKindList.value.length - 1];
-  
-  // 如果没有行,或者最后一行不是新增行,允许添加新行
-  if (!lastRow || !lastRow.isNewRow) {
-    canAddNewRow.value = true; // 允许添加新行
+const handleAddOrder = async () => {
+  // 表单校验
+  if (!actionForm.value.actionType) {
+    console.warn('请选择下拉列表值');
     return;
     return;
   }
   }
 
 
-  // 如果最后一行是新增行,检查必填字段
-  canAddNewRow.value = lastRow.departureCode && lastRow.arrivalCode && lastRow.systemCode;
-}
-
-//増便
-const addNewRow = () => {
-  const newRow = {
-    AM: '',
-    departureCode: '',
-    arrivalCode: '',
-    systemCode: '',
-    lineName: '',
-    wareHouseLocation: '',
-    wareHouseTime: '',
-    vehicleTon: '',
-    isNewRow: true,
-    highlightRow: true // 新增高亮标记
-  }
-  
-  for (let i = 1; i <= 31; i++) {
-    newRow[`num_${i}`] = ''
+  try {
+    // 调用 API
+    const response = await addOrder(actionForm.value);
+    if (response.code === 200) {
+      // 成功提示
+      proxy.$message.success('登録成功');
+    }
+  } catch (error) {
+    proxy.$message.error('操作失败:' + error.message);
   }
   }
-  
-  examKindList.value.push(newRow);
-  checkAddButtonState();
-}
+
+  // 重置表单
+  actionForm.value = {
+    actionType: '',
+    actionComment: '',
+    actionCode: resultId
+  };
+  getActionList();
+};
 
 
 const tableRowClassName = ({row}) => {
 const tableRowClassName = ({row}) => {
   return row.highlightRow ? 'highlight-row' : ''
   return row.highlightRow ? 'highlight-row' : ''
@@ -218,6 +241,15 @@ const reasonOptions = ref([
   { value: 'option2', label: '选项2' },
   { value: 'option2', label: '选项2' },
   { value: 'option3', label: '选项3' }
   { value: 'option3', label: '选项3' }
 ])
 ])
+const actionTypeOptions = ref([
+  { value: '10', label: '指示書連携' },
+  { value: '11', label: 'コメント登録' },
+  { value: '12', label: 'コメント受領' },
+  { value: '13', label: 'コメント送付' },
+  { value: '14', label: '指示書送付' },
+  { value: '15', label: 'キャンセル連絡' },
+  { value: '16', label: 'メモ登録' }
+])
 // 绑定下拉框的值
 // 绑定下拉框的值
 const selectedReason = ref('');
 const selectedReason = ref('');
 // 绑定文本框的值
 // 绑定文本框的值
@@ -254,18 +286,18 @@ const handleEnter = () => {
     const originalItem = originalDataList.value[index];
     const originalItem = originalDataList.value[index];
     
     
     // 获取原始值(从 originalData 对象中)
     // 获取原始值(从 originalData 对象中)
-    const originalValue = originalItem?.originalData || '';
+    const originalValue = originalItem?.charterFee || '';
     const currentValue = currentRow.value[`num_${currentNum.value}`] || '';
     const currentValue = currentRow.value[`num_${currentNum.value}`] || '';
     
     
     
     
      if (!originalValue && valueToUpdate) {
      if (!originalValue && valueToUpdate) {
-       originalItem.originalData = '〇';
+       originalItem.charterFee = '〇';
     } else if (valueToUpdate === originalValue) {
     } else if (valueToUpdate === originalValue) {
       // 保持原值,不做任何修改
       // 保持原值,不做任何修改
     } else {
     } else {
       // 添加 valueToUpdate 不为空的判断
       // 添加 valueToUpdate 不为空的判断
       if (valueToUpdate !== '') { 
       if (valueToUpdate !== '') { 
-        originalItem.originalData = '';
+        originalItem.charterFee = '';
       }
       }
     }
     }
     
     
@@ -300,19 +332,7 @@ const submitFormLoading = ref(false);
 const listTotalCnt = ref(0);
 const listTotalCnt = ref(0);
 const dialogTitle = ref("");
 const dialogTitle = ref("");
 
 
-const data = reactive({
-  form: {},
-  queryParams: {
-    pageNum: 1,
-    pageSize: 10,
-    certificationType: null,
-    examName: null,
-  },
-  rules: {
-    certificationType: [{required: true, message: formatMsg('E0003', "検定種類"), trigger: 'blur'}],
-    examName: [{required: true, message: formatMsg('E0003', "試験名"), trigger: 'blur'}],
-  }
-});
+const data = reactive({});
 
 
 const {queryParams, form, rules} = toRefs(data);
 const {queryParams, form, rules} = toRefs(data);
 
 
@@ -327,12 +347,10 @@ const getElement = (num) => {
  */
  */
 const getList = () => {
 const getList = () => {
   listLoading.value = true;
   listLoading.value = true;
-  const data = { orderId };
+  const data = { resultId };
   getOrderCompilation(data).then(response => {
   getOrderCompilation(data).then(response => {
     const originalData = response.data;
     const originalData = response.data;
-    const filteredData = originalData.filter(item => {
-      return item.monthPlanId !== undefined && item.monthPlanId !== null && item.monthPlanId !== '';
-    });
+    const filteredData = originalData;
 
 
     originalDataLength.value = filteredData.length;
     originalDataLength.value = filteredData.length;
     
     
@@ -347,7 +365,7 @@ const getList = () => {
     initialData.value = JSON.parse(JSON.stringify(enhancedData)); // 深拷贝初始状态
     initialData.value = JSON.parse(JSON.stringify(enhancedData)); // 深拷贝初始状态
 
 
     const uniqueData = Array.from(
     const uniqueData = Array.from(
-      new Map(originalData.map(item => [item.monthPlanId, item])).values()
+      new Map(originalData.map(item => [item.vehicleRouter, item])).values()
     );
     );
     
     
     examKindList.value = initializeData(uniqueData);
     examKindList.value = initializeData(uniqueData);
@@ -356,35 +374,8 @@ const getList = () => {
   });
   });
 };
 };
 
 
-const discardChanges = () => {
-  // 删除所有新增行(isNewRow为true)
-  const existingRows = examKindList.value.filter(row => !row.isNewRow);
-  
-  // 恢复现有行的原始数据
-  const originalExistingData = originalDataList.value.slice(0, existingRows.length); // 假设原始数据顺序与现有行一致
-  
-  examKindList.value = existingRows.map((row, index) => {
-    const originalRow = originalExistingData[index];
-    return {
-      ...row,
-      // 恢复原始数据中的字段(根据实际字段调整)
-      ...originalRow,
-      __modifiedFields: [], // 清空修改标记 
-      isNewRow: false // 现有行不再是新增行
-    };
-  });
-
-  // 重置原始数据引用(可选)
-  originalDataList.value = JSON.parse(JSON.stringify(initialData.value));
-  isSaved.value = false; // 允许再次保存
-  checkAddButtonState();
-};
-const getRunWeekDayByIndex = (index) => {
-  return originalDataList.value[index]?.originalData || '';
-};
-
-const getNewDataByIndex = (index) => {
-  return originalDataList.value[index]?.newData || '';
+const getCharterFeeByIndex = (index) => {
+  return originalDataList.value[index]?.charterFee || '';
 };
 };
 
 
 const saveChanges = async () => {
 const saveChanges = async () => {
@@ -405,8 +396,7 @@ const saveChanges = async () => {
             const originalItem = originalDataList.value[runDay - 1];
             const originalItem = originalDataList.value[runDay - 1];
             
             
             if (originalItem) {
             if (originalItem) {
-              // 获取 monthPlanId runWeekDay
-              const monthPlanId = originalItem.monthPlanId;
+              // 获取runWeekDay
               const runWeekDay = originalItem.runWeekDay;
               const runWeekDay = originalItem.runWeekDay;
               
               
               // 获取当前值和原始值
               // 获取当前值和原始值
@@ -426,7 +416,7 @@ const saveChanges = async () => {
               
               
               // 添加到修改列表
               // 添加到修改列表
               modifiedCells.push({
               modifiedCells.push({
-                monthPlanId,
+                resultId,
                 runDay,
                 runDay,
                 runWeekDay,
                 runWeekDay,
                 changeFlag,
                 changeFlag,
@@ -448,21 +438,12 @@ const saveChanges = async () => {
       // 处理成功响应
       // 处理成功响应
       if (response.code === 200) {
       if (response.code === 200) {
         proxy.$message.success('保存成功');
         proxy.$message.success('保存成功');
-         isSaved.value = true; 
           const actionType = 14
           const actionType = 14
-          const newFlag = 1
-          const actionCode = orderId
+          const actionCode = resultId
           await addOrder({
           await addOrder({
              actionType,
              actionType,
              actionCode
              actionCode
           })
           })
-           router.push({
-    name: 'OrderDetail',
-    query: { 
-      newFlag: newFlag,
-      version: version.value
-    }
-  });
       } else {
       } else {
         proxy.$message.error(response.msg || '保存失败');
         proxy.$message.error(response.msg || '保存失败');
       }
       }
@@ -478,6 +459,7 @@ const saveChanges = async () => {
   }
   }
 };
 };
 getList();
 getList();
+getActionList();
 </script>
 </script>
 <style>
 <style>
 .eikin-dialog-edit {
 .eikin-dialog-edit {