From b46bc2dba51a3885a68e4c58316b41a31ea16bb2 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 14 二月 2023 13:35:03 +0800
Subject: [PATCH] 1.存货档案修改

---
 src/views/scgl/cngh.vue |  737 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 506 insertions(+), 231 deletions(-)

diff --git a/src/views/scgl/cngh.vue b/src/views/scgl/cngh.vue
index e68cff2..e54c9b0 100644
--- a/src/views/scgl/cngh.vue
+++ b/src/views/scgl/cngh.vue
@@ -2,7 +2,7 @@
   <div>
     <div class="body" :style="{height:mainHeight+'px'}">
       <div class="bodyTopButtonGroup" style="justify-content: space-between">
-        <el-button type="primary" icon="el-icon-setting" @click="setting('setting')">璁剧疆</el-button>
+        <el-button v-waves type="primary" icon="el-icon-setting" @click="setting('setting')">璁剧疆</el-button>
       </div>
 
       <div class="bodyTopFormGroup">
@@ -11,14 +11,15 @@
           :model="form"
           label-width="100px"
           inline
-          style="display: flex;justify-content: space-between"
+          style="display: flex;"
         >
-          <div class="elForm" style="justify-content: flex-start">
-            <el-form-item label-width="70px" label="鐢熶骇杞﹂棿" style=" display: flex;">
+          <div class="elForm">
+            <el-form-item label="鐢熶骇杞﹂棿" style=" display: flex;">
               <el-select
                 v-model="form.workshop"
                 style="width: 200px"
                 placeholder="璇烽�夋嫨"
+                @change="getWhkspIsEqpSearch"
               >
                 <el-option
                   v-for="item in workshopArr"
@@ -33,12 +34,13 @@
                 v-model="form.devicetype"
                 style="width: 200px"
                 placeholder="璇烽�夋嫨"
+                :disabled="form.workshop===''"
               >
                 <el-option
                   v-for="item in devicetypeArr"
-                  :key="item.code"
-                  :label="item.name"
-                  :value="item.code"
+                  :key="item.eqp_code"
+                  :label="item.eqp_name"
+                  :value="item.eqp_code"
                 />
               </el-select>
             </el-form-item>
@@ -54,9 +56,9 @@
             </el-form-item>
 
           </div>
-          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened?'5%':'10%'}">
-            <el-button type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
-            <el-button type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}">
+            <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
+            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
           </div>
         </el-form>
         <div
@@ -67,7 +69,7 @@
       <div class="elTableDiv">
         <el-table
           ref="tableDataRef"
-          class="tableFixed"
+          class="tableFixed table_only"
           :data="tableData"
           :style="{width: 100+'%',height:tableHeight+'px'}"
           border
@@ -89,11 +91,13 @@
             label="鐢熶骇杞﹂棿"
             sortable="custom"
             width="160"
+            show-tooltip-when-overflow
           />
           <el-table-column
             prop="CaptPlanDeviceType"
             label="鐢熶骇鍗曞厓"
             width="160"
+            show-tooltip-when-overflow
             sortable="custom"
           />
           <el-table-column
@@ -109,6 +113,7 @@
                   readonly
                 />
                 <el-button
+
                   type="primary"
                   style="padding: 0 10px;margin-left: 5px"
                   class="el-icon-search"
@@ -120,13 +125,17 @@
             prop="CaptPlanShopCalendarList"
             label="宸ヤ綔鏃ュ巻"
             sortable="custom"
+            min-width="300"
           >
             <template slot-scope="{row}">
+              <el-input v-if="row.CaptPlanWorkShift===null" :disabled="row.CaptPlanWorkShift===null" />
               <date-picker
+                v-else
                 v-model="row.CaptPlanShopCalendarList"
                 :row-data="row"
                 style="width: 100%;"
                 :capacity-planning-search="CapacityPlanningSearch"
+                @over="over"
               />
             </template>
           </el-table-column>
@@ -134,50 +143,36 @@
             prop="CaptPlanUser"
             label="鍒涘缓浜哄憳"
             sortable="custom"
-            width="160"
+            show-tooltip-when-overflow
+            width="120"
           />
           <el-table-column
             prop="CaptPlanDate"
             width="160"
             label="鍒涘缓鏃堕棿"
+            show-tooltip-when-overflow
             sortable="custom"
           />
 
           <el-table-column
             prop="CaptPlanStus"
-            width="160"
+            width="120"
             label="鏈夋晥鐘舵��"
             sortable="custom"
+            show-tooltip-when-overflow
           >
             <template slot-scope="{row}">
               <div v-if="row.CaptPlanStus==='Y'">
-                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
+                <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
                 鏈夋晥
               </div>
               <div v-else-if="row.CaptPlanStus==='N'">
-                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
+                <i class="el-icon-info" style="margin-right: 2px" />
                 鏃犳晥
               </div>
               <div v-else>/</div>
             </template>
           </el-table-column>
-
-          <!--          <el-table-column-->
-          <!--            label="鎿嶄綔"-->
-          <!--            width="120"-->
-          <!--            fixed="right"-->
-          <!--          >-->
-          <!--            <template slot-scope="{row}">-->
-          <!--              <div class="operationClass">-->
-          <!--                <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">-->
-          <!--                  <i class="el-icon-edit-outline" @click="edit('edit',row)" />-->
-          <!--                </el-tooltip>-->
-          <!--                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">-->
-          <!--                  <i class="el-icon-delete" @click="del(row)" />-->
-          <!--                </el-tooltip>-->
-          <!--              </div>-->
-          <!--            </template>-->
-          <!--          </el-table-column>-->
         </el-table>
       </div>
       <!--鍒嗛〉-->
@@ -193,17 +188,20 @@
     </div>
 
     <el-dialog
+      v-el-drag-dialog
       :title="operation==='setting'?'璁剧疆':'榛樿鏂规'"
       :visible.sync="dialogVisible"
-      width="1280px"
+      width="1360px"
       :close-on-click-modal="false"
       top="10vh"
       @closed="handleClose"
       @close="handleClose"
     >
-      <el-button v-if="operation==='setting'" type="primary" @click="addRow">鏂板</el-button>
+      <el-button v-if="operation==='setting'" v-waves type="primary" @click="addRow">鏂板</el-button>
       <div class="elTableDiv">
+        <!--        閫夋嫨榛樿鏂规鐨勬椂鍊欐槸杩欎釜table-->
         <el-table
+          v-if="operation!=='setting'"
           ref="tableDataDialogRef"
           class="tableFixedDialog"
           :data="tableDataDialog"
@@ -214,132 +212,174 @@
           highlight-current-row
           :header-cell-style="this.$headerCellStyle"
           :cell-style="this.$cellStyle"
+          @row-click="rowClick"
         >
 
           <el-table-column
-            v-if="operation!=='setting'"
             width="50"
             fixed
           >
             <template slot-scope="{row}">
               <el-radio
-                v-model="radioSelectedId"
-                :label="row.hx"
+                v-model="radioSelectedCode"
+                :label="row.code"
                 style="padding-left: 10px;"
-                @change.native="getCurrentRowSource(row.hx)"
               />
+              <!--              @change.native="getCurrentRowSource(row.code)"-->
+
             </template>
           </el-table-column>
           <el-table-column
-            prop="famc"
+            prop="code"
+            label="鏂规缂栫爜"
+            width="100"
+            show-tooltip-when-overflow
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">{{ row.code }}</div>
+              <el-input v-else v-model="row.code" placeholder="璇疯緭鍏�" type="text" />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="name"
             label="鏂规鍚嶇О"
             width="150"
             fixed
             show-tooltip-when-overflow
           >
             <template slot-scope="{row}">
-              <el-input v-model="row.famc" :disabled="row.isVisible===0" type="text" />
+              <div v-if="row.isVisible===0">{{ row.name }}</div>
+              <el-input v-else v-model="row.name" placeholder="璇疯緭鍏�" type="text" />
             </template>
           </el-table-column>
           <el-table-column
-            prop="gzsc"
+            prop="duration"
             label="宸ヤ綔鏃堕暱"
             width="100"
             show-tooltip-when-overflow
-          />
+          >
+            <template slot-scope="{row}">
+              <div>{{ row.duration ? parseFloat(row.duration.toFixed(2)) : '0' }} 灏忔椂</div>
+            </template>
+          </el-table-column>
 
           <el-table-column
-            prop="time1"
+            prop="wktme1_start"
             label="宸ヤ綔鏃堕棿涓�"
           >
             <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme1_start">{{ row.wktme1_start }}</div>
+                <div v-else>/</div>
+              </div>
               <el-time-picker
-                v-model="row.time1"
+                v-else
+                v-model="row.wktme1_start"
                 is-range
-                :disabled="row.isVisible===0"
                 :editable="false"
                 :clearable="false"
                 range-separator="~"
                 start-placeholder="寮�濮�"
                 end-placeholder="缁撴潫"
                 format="HH:mm"
-                @focus="val=>getTime(val,row,'time1')"
+                @focus="val=>getTime(val,row,'wktme1_start')"
               />
             </template>
           </el-table-column>
           <el-table-column
-            prop="time2"
+            prop="wktme2_start"
             label="宸ヤ綔鏃堕棿浜�"
           >
             <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme2_start">{{ row.wktme2_start }}</div>
+                <div v-else>/</div>
+              </div>
               <el-time-picker
-                v-model="row.time2"
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme2_start"
                 is-range
-                :disabled="row.isVisible===0"
+                :disabled="row.wktme1_start.length===0"
                 :editable="false"
                 :clearable="false"
                 range-separator="~"
                 start-placeholder="寮�濮�"
                 end-placeholder="缁撴潫"
                 format="HH:mm"
-                @focus="val=>getTime(val,row,'time2')"
+                @focus="val=>getTime(val,row,'wktme2_start')"
               />
             </template>
           </el-table-column>
           <el-table-column
-            prop="time3"
+            prop="wktme3_start"
             label="宸ヤ綔鏃堕棿涓�"
           >
             <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme3_start">{{ row.wktme3_start }}</div>
+                <div v-else>/</div>
+              </div>
               <el-time-picker
-                v-model="row.time3"
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme3_start"
                 is-range
+                :disabled="row.wktme2_start.length===0"
                 :editable="false"
-                :disabled="row.isVisible===0"
                 :clearable="false"
                 format="HH:mm"
                 range-separator="~"
                 start-placeholder="寮�濮�"
                 end-placeholder="缁撴潫"
-                @focus="val=>getTime(val,row,'time3')"
+                @focus="val=>getTime(val,row,'wktme3_start')"
               />
             </template>
           </el-table-column>
           <el-table-column
-            prop="time4"
+            prop="wktme4_start"
             label="宸ヤ綔鏃堕棿鍥�"
           >
             <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme4_start">{{ row.wktme4_start }}</div>
+                <div v-else>/</div>
+              </div>
               <el-time-picker
-                v-model="row.time4"
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme4_start"
                 is-range
+                :disabled="row.wktme3_start.length===0"
                 format="HH:mm"
-                :editable="false"
-                :disabled="row.isVisible===0"
                 :clearable="false"
+                :editable="false"
                 range-separator="~"
                 start-placeholder="寮�濮�"
                 end-placeholder="缁撴潫"
-                @focus="val=>getTime(val,row,'time4')"
+                @focus="val=>getTime(val,row,'wktme4_start')"
               />
+
             </template>
           </el-table-column>
           <el-table-column
-            prop="time5"
+            prop="wktme5_start"
             label="宸ヤ綔鏃堕棿浜�"
           >
             <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme5_start">{{ row.wktme5_start }}</div>
+                <div v-else>/</div>
+              </div>
               <el-time-picker
-                v-model="row.time5"
-                :disabled="row.isVisible===0"
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme5_start"
                 is-range
+                :disabled="row.wktme4_start.length===0"
+                :clearable="false"
                 :editable="false"
                 format="HH:mm"
-                :clearable="false"
                 range-separator="~"
                 start-placeholder="寮�濮�"
                 end-placeholder="缁撴潫"
-                @focus="val=>getTime(val,row,'time5')"
+                @focus="val=>getTime(val,row,'wktme5_start')"
               />
             </template>
           </el-table-column>
@@ -351,9 +391,198 @@
           >
             <template slot-scope="{row}">
               <div class="operationClass">
-                <el-button v-if="row.isVisible===0" type="text" @click="editRow(row)">缂栬緫</el-button>
-                <el-button v-if="row.isVisible===0" type="text" @click="delRow(row)">鍒犻櫎</el-button>
-                <el-button v-if="row.isVisible===1" type="text" @click="saveRow(row)">淇濆瓨</el-button>
+                <el-button v-if="row.isVisible===0" v-waves type="text" @click="delRow(row)">鍒犻櫎</el-button>
+                <el-button v-if="row.isVisible===1" v-waves type="text" @click="saveRow(row)">淇濆瓨</el-button>
+                <el-button v-if="row.isVisible===1" v-waves type="text" @click="cancelRow(row)">鍙栨秷</el-button>
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+        <!--      璁剧疆鐨勬椂鍊欐槸杩欎釜table-->
+        <el-table
+          v-else
+          ref="tableDataDialogRef"
+          class="tableFixedDialog"
+          :data="tableDataDialog"
+          :style="{width: 100+'%',height:(tableHeight-200)+'px'}"
+          border
+          :height="(tableHeight-200)+'px'"
+          :row-class-name="tableRowClassName"
+          highlight-current-row
+          :header-cell-style="this.$headerCellStyle"
+          :cell-style="this.$cellStyle"
+        >
+          <el-table-column
+            prop="code"
+            label="鏂规缂栫爜"
+            width="100"
+            fixed
+            show-tooltip-when-overflow
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">{{ row.code }}</div>
+              <el-input v-else v-model="row.code" placeholder="璇疯緭鍏�" type="text" />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="name"
+            label="鏂规鍚嶇О"
+            width="150"
+            fixed
+            show-tooltip-when-overflow
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">{{ row.name }}</div>
+              <el-input v-else v-model="row.name" placeholder="璇疯緭鍏�" type="text" />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="duration"
+            label="宸ヤ綔鏃堕暱"
+            width="100"
+            show-tooltip-when-overflow
+          >
+            <template slot-scope="{row}">
+              <div>{{ row.duration ? parseFloat(row.duration.toFixed(2)) : '0' }} 灏忔椂</div>
+            </template>
+          </el-table-column>
+
+          <el-table-column
+            prop="wktme1_start"
+            label="宸ヤ綔鏃堕棿涓�"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme1_start">{{ row.wktme1_start }}</div>
+                <div v-else>/</div>
+              </div>
+              <el-time-picker
+                v-else
+                v-model="row.wktme1_start"
+                is-range
+                :editable="false"
+                :clearable="false"
+                range-separator="~"
+                start-placeholder="寮�濮�"
+                end-placeholder="缁撴潫"
+                format="HH:mm"
+                @blur="val=>getTime(val,row,'wktme1_start')"
+                @focus="val=>getTime(val,row,'wktme1_start')"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="wktme2_start"
+            label="宸ヤ綔鏃堕棿浜�"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme2_start">{{ row.wktme2_start }}</div>
+                <div v-else>/</div>
+              </div>
+              <el-time-picker
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme2_start"
+                is-range
+                :disabled="row.wktme1_start.length===0"
+                :editable="false"
+                :clearable="false"
+                range-separator="~"
+                start-placeholder="寮�濮�"
+                end-placeholder="缁撴潫"
+                format="HH:mm"
+                @blur="val=>getTime(val,row,'wktme2_start')"
+                @focus="val=>getTime(val,row,'wktme2_start')"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="wktme3_start"
+            label="宸ヤ綔鏃堕棿涓�"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme3_start">{{ row.wktme3_start }}</div>
+                <div v-else>/</div>
+              </div>
+              <el-time-picker
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme3_start"
+                is-range
+                :disabled="row.wktme2_start.length===0"
+                :editable="false"
+                :clearable="false"
+                format="HH:mm"
+                range-separator="~"
+                start-placeholder="寮�濮�"
+                end-placeholder="缁撴潫"
+                @blur="val=>getTime(val,row,'wktme3_start')"
+                @focus="val=>getTime(val,row,'wktme3_start')"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="wktme4_start"
+            label="宸ヤ綔鏃堕棿鍥�"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme4_start">{{ row.wktme4_start }}</div>
+                <div v-else>/</div>
+              </div>
+              <el-time-picker
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme4_start"
+                is-range
+                :disabled="row.wktme3_start.length===0"
+                format="HH:mm"
+                :clearable="false"
+                :editable="false"
+                range-separator="~"
+                start-placeholder="寮�濮�"
+                end-placeholder="缁撴潫"
+                @blur="val=>getTime(val,row,'wktme4_start')"
+                @focus="val=>getTime(val,row,'wktme4_start')"
+              />
+
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="wktme5_start"
+            label="宸ヤ綔鏃堕棿浜�"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.isVisible===0">
+                <div v-if="row.wktme5_start">{{ row.wktme5_start }}</div>
+                <div v-else>/</div>
+              </div>
+              <el-time-picker
+                v-else-if="row.isVisible===1"
+                v-model="row.wktme5_start"
+                is-range
+                :disabled="row.wktme4_start.length===0"
+                :clearable="false"
+                :editable="false"
+                format="HH:mm"
+                range-separator="~"
+                start-placeholder="寮�濮�"
+                end-placeholder="缁撴潫"
+                @blur="val=>getTime(val,row,'wktme5_start')"
+                @focus="val=>getTime(val,row,'wktme5_start')"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column
+            v-if="operation==='setting'"
+            width="100"
+            fixed="right"
+            label="鎿嶄綔"
+          >
+            <template slot-scope="{row}">
+              <div class="operationClass">
+                <el-button v-if="row.isVisible===0" v-waves type="text" @click="delRow(row)">鍒犻櫎</el-button>
+                <el-button v-if="row.isVisible===1" v-waves type="text" @click="saveRow(row)">淇濆瓨</el-button>
+                <el-button v-if="row.isVisible===1" v-waves type="text" @click="cancelRow(row)">鍙栨秷</el-button>
               </div>
             </template>
           </el-table-column>
@@ -361,41 +590,42 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
-          <el-button @click="dialogVisibleCancel">杩� 鍥�</el-button>
-          <el-button v-if="operation!=='setting'" type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+          <el-button v-waves @click="dialogVisibleCancel">杩� 鍥�</el-button>
+          <el-button
+            v-if="operation!=='setting'"
+            v-waves
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="dialogVisibleConfirm"
+          >纭� 瀹�</el-button>
         </div>
       </span>
     </el-dialog>
-
-    <!--瀵煎叆缁勪欢-->
-    <import-picker
-      ref="importPickerFunc"
-      class="importPickerClass"
-      :shows.sync="shows"
-      :title="title_value"
-      :colos="colos"
-      :code="code"
-    />
-
   </div>
 </template>
 
 <script>
 import Pagination from '@/components/Pagination'
-import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
-import { getCookie } from '@/utils/auth'
-import ImportPicker from '@/components/ImportPicker'
-import { validateCode } from '@/utils/global'
-import $ from 'jquery'
 import DatePicker from '@/components/DatePicker'
-import { CapacityPlanningSearch } from '@/api/scgl'
+import {
+  CapacityPlanningSearch,
+  CapacityPlanningSetupAddUpdate,
+  CapacityPlanningSetupDelete,
+  CapacityPlanningSetupSearch, CapacityPlanSubmit
+} from '@/api/scgl'
 import { DeviceTypeSelect, WorkShopSelect } from '@/api/sbgl'
+import { handleDatetime3 } from '@/utils/global'
+import { WhkspIsEqpSearch } from '@/api/jcsz'
+import elDragDialog from '@/directive/el-drag-dialog'
+import waves from '@/directive/waves'
 
 export default {
   name: 'Zzjg',
   components: {
-    Pagination, ImportPicker, DatePicker
+    Pagination, DatePicker
   },
+  directives: { elDragDialog, waves },
   data() {
     return {
       mouseHoverType: 'mouseout',
@@ -419,14 +649,7 @@
       devicetypeArr: [],
       total: 10,
       tableData: [],
-
       dialogVisible: false,
-      dialogForm: {
-        // OrgType: '',
-        // OrgCode: '',
-        // OrgName: '',
-        // SupUnit: ''// 涓婄骇鍗曚綅
-      },
       operation: '',
       pickerOptions: {
         disabledDate(time) {
@@ -436,82 +659,84 @@
           // return time.getTime() < Date.now(); // 涓嶅彲閫夊巻鍙插ぉ銆佷笉鍙�夊綋鍓嶅ぉ銆佸彲閫夋湭鏉ュぉ
         }
       },
-      popoverVisible: false,
-      available: null,
-      nextMonth: null,
-
-      tableDataDialog: [
-        // {
-        //   famc: '鏂规涓�',
-        //   gzsc: '8灏忔椂',
-        //   time1: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)],
-        //   time2: '',
-        //   time3: '',
-        //   time4: '',
-        //   time5: ''
-        // }
-      ],
-      radioSelectedId: '',
-
-      title_value: '鏁版嵁瀵煎叆 / 鐐规閮ㄤ綅',
-      code: '4',
-      shows: false
+      tableDataDialog: [],
+      radioSelectedCode: '',
+      tempObj: {} // 涓存椂瀵硅薄锛岄粯璁ゆ柟妗堟彁浜ゆ椂浣跨敤
 
     }
   },
-  watch: {
-    shows() {
-      if (!this.shows) {
-        this.getCapacityPlanningSearch()
-      }
-    }
-  },
+
   created() {
-
+    this.handleRequest()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
-
-    this.handleRequest()
-    // this.getDialogData()
   },
   methods: {
-    getCurrentRowSource() {
-
+    // 琛岀偣鍑讳簨浠�
+    rowClick(row, event, column) {
+      this.radioSelectedCode = row.code
     },
-    getDialogData() {
-      let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
-      number = number === 0 ? (10 + Math.random()) : number
-      this.tableDataDialog.push(
-        {
-          hx: 1,
-          famc: '鏂规涓�',
-          gzsc: '8灏忔椂',
-          time1: [],
-          time2: [],
-          time3: [],
-          time4: [],
-          time5: [],
-          number,
-          isVisible: 0
-        }
-      )
+    // 瀛愮粍浠跺け鐒︽椂鎵ц
+    over(val) {
+      if (val) {
+        // console.log(val)
+        this.getCapacityPlanningSearch()
+      }
+    },
+    getCurrentRowSource(code) {
+      this.radioSelectedCode = code
+    },
+    async getDialogData() {
+      const { data: res } = await CapacityPlanningSetupSearch()
+      this.tableDataDialog = res
+
+      this.tableDataDialog.forEach(item => {
+        let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
+        number = number === 0 ? (10 + Math.random()) : number
+        item.number = number
+        item.isVisible = 0
+        item.duration = this.computingTime(item.wktme1_start, item.wktme2_start, item.wktme3_start, item.wktme4_start, item.wktme5_start)
+      })
+    },
+    // 璁$畻鏃堕棿鐨勬柟娉�  杩斿洖 澶氬皯灏忔椂
+    computingTime(time1, time2, time3, time4, time5) {
+      //   杞垚鍒嗛挓璁$畻
+      const second1 = time1 ? calcTime(time1) : null
+      const second2 = time2 ? calcTime(time2) : null
+      const second3 = time3 ? calcTime(time3) : null
+      const second4 = time4 ? calcTime(time4) : null
+      const second5 = time5 ? calcTime(time5) : null
+      return (second1 + second2 + second3 + second4 + second5) / 60
+
+      // 涓や釜鏃堕棿宸��  杞寲涓哄垎閽熸暟
+      function calcTime(val) {
+        return (parseInt(val.split('~')[1].split(':')[0]) * 60 + parseInt(val.split('~')[1].split(':')[1])) - (parseInt(val.split('~')[0].split(':')[0]) * 60 + parseInt(val.split('~')[0].split(':')[1]))
+      }
     },
     getTime(val, row, belong) {
-      const res = this.getDt()
-      if (belong === 'time1') {
-        // row.time1.push(new Date(res.yyyy, res.MM, res.dd, '00', '00'))
-        row.time1 = row.time1.length > 0 ? row.time1 : row.time1.push(new Date())
-      } else if (belong === 'time2') {
-        row.time2 = row.time2.length > 0 ? row.time2 : row.time2.push(new Date())
-      } else if (belong === 'time3') {
-        row.time3 = row.time3.length > 0 ? row.time3 : row.time3.push(new Date())
-      } else if (belong === 'time4') {
-        row.time4 = row.time4.length > 0 ? row.time4 : row.time4.push(new Date())
-      } else if (belong === 'time5') {
-        row.time5 = row.time5.length > 0 ? row.time5 : row.time5.push(new Date())
+      // const res = this.getDt()
+      if (belong === 'wktme1_start') {
+        // row.wktme1_start.push(new Date(res.yyyy, res.MM, res.dd, '00', '00'))
+        row.wktme1_start = row.wktme1_start.length > 0 ? row.wktme1_start : row.wktme1_start.push(new Date())
+      } else if (belong === 'wktme2_start') {
+        row.wktme2_start = row.wktme2_start.length > 0 ? row.wktme2_start : row.wktme2_start.push(new Date())
+      } else if (belong === 'wktme3_start') {
+        row.wktme3_start = row.wktme3_start.length > 0 ? row.wktme3_start : row.wktme3_start.push(new Date())
+      } else if (belong === 'wktme4_start') {
+        row.wktme4_start = row.wktme4_start.length > 0 ? row.wktme4_start : row.wktme4_start.push(new Date())
+      } else if (belong === 'wktme5_start') {
+        row.wktme5_start = row.wktme5_start.length > 0 ? row.wktme5_start : row.wktme5_start.push(new Date())
       }
+
+      const duration = this.computingTime(handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]),
+        row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : null,
+        row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : null,
+        row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : null,
+        row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : null)
+      row.duration = parseFloat(duration.toFixed(2))
+      console.log(row.duration)
     },
     getDt() {
       const dt = new Date()
@@ -527,38 +752,101 @@
       return { yyyy: y, MM: m, dd: d, hh, mm }
     },
     addRow() {
+      const temp = this.tableDataDialog.find(item => item.isVisible === 1)
+      if (temp) {
+        return this.$message.info('璇峰厛淇濆瓨涓婁竴鏉¤褰曪紒')
+      }
+
+      let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
+      number = number === 0 ? (10 + Math.random()) : number
       this.tableDataDialog.push(
         {
-          hx: 2,
-          famc: '鏂规xxx',
-          gzsc: '8灏忔椂',
-          time1: [],
-          time2: [],
-          time3: [],
-          time4: [],
-          time5: [],
-          isVisible: 1
+          RowNum: 2,
+          code: '',
+          name: '',
+          duration: '',
+          wktme1_start: [],
+          wktme2_start: [],
+          wktme3_start: [],
+          wktme4_start: [],
+          wktme5_start: [],
+          isVisible: 1,
+          number
         }
       )
     },
-    editRow(row) {
-      console.log(row)
-      row.isVisible = 1
+    cancelRow(row) {
+      this.tableDataDialog.forEach((item, index) => {
+        if (row.number === item.number) {
+          this.tableDataDialog.splice(index, 1)
+        }
+      })
     },
-    saveRow(row) {
-      row.isVisible = 0
-    },
-    delRow(row) {
+    async saveRow(row) {
+      if (row.code.trim().toString().length === 0) {
+        return this.$message.info('鏂规缂栫爜涓嶈兘涓虹┖锛�')
+      }
+      if (row.name.trim().toString().length === 0) {
+        return this.$message.info('鏂规鍚嶇О涓嶈兘涓虹┖锛�')
+      }
+      if (row.wktme1_start.length === 0) {
+        return this.$message.info('宸ヤ綔鏃堕棿涓嶈兘涓虹┖锛屼繚瀛樺け璐ワ紒')
+      }
+      // 淇濆瓨鏃堕渶瑕佸厛鍒ゆ柇宸ヤ綔鏃堕棿鍚庨潰鐨勪笉鑳藉皬浜庡墠闈㈢殑
+      // 鍏堝彇鍑烘潵瀛樿浆鍖栨垚鍒嗛挓瀛樻垚鏁扮粍杩涜澶у皬瀵规瘮
+      if (calcTime(handleDatetime3(row.wktme1_start[1]), handleDatetime3(row.wktme2_start[0]))) {
+        return this.$message.info('宸ヤ綔鏃堕棿浜岀殑寮�濮嬫椂闂村皬浜庝簡宸ヤ綔鏃堕棿涓�鐨勭粨鏉熸椂闂达紝淇濆瓨澶辫触锛�')
+      }
+      if (calcTime(handleDatetime3(row.wktme2_start[1]), handleDatetime3(row.wktme3_start[0]))) {
+        return this.$message.info('宸ヤ綔鏃堕棿涓夌殑寮�濮嬫椂闂村皬浜庝簡宸ヤ綔鏃堕棿浜岀殑缁撴潫鏃堕棿锛屼繚瀛樺け璐ワ紒')
+      }
+      if (calcTime(handleDatetime3(row.wktme3_start[1]), handleDatetime3(row.wktme4_start[0]))) {
+        return this.$message.info('宸ヤ綔鏃堕棿鍥涚殑寮�濮嬫椂闂村皬浜庝簡宸ヤ綔鏃堕棿涓夌殑缁撴潫鏃堕棿锛屼繚瀛樺け璐ワ紒')
+      }
+      if (calcTime(handleDatetime3(row.wktme4_start[1]), handleDatetime3(row.wktme5_start[0]))) {
+        return this.$message.info('宸ヤ綔鏃堕棿浜旂殑寮�濮嬫椂闂村皬浜庝簡宸ヤ綔鏃堕棿鍥涚殑缁撴潫鏃堕棿锛屼繚瀛樺け璐ワ紒')
+      }
+      const Duration = this.computingTime(handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]),
+        row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : null,
+        row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : null,
+        row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : null,
+        row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : null)
+      const data = {
+        CapSetupCode: row.code,
+        CapSetupName: row.name,
+        OneStartDate: row.wktme1_start.length !== 0 ? handleDatetime3(row.wktme1_start[0]) + '~' + handleDatetime3(row.wktme1_start[1]) : '',
+        TwoStartDate: row.wktme2_start.length !== 0 ? handleDatetime3(row.wktme2_start[0]) + '~' + handleDatetime3(row.wktme2_start[1]) : '',
+        ThreeStartDate: row.wktme3_start.length !== 0 ? handleDatetime3(row.wktme3_start[0]) + '~' + handleDatetime3(row.wktme3_start[1]) : '',
+        FourStartDate: row.wktme4_start.length !== 0 ? handleDatetime3(row.wktme4_start[0]) + '~' + handleDatetime3(row.wktme4_start[1]) : '',
+        FiveStartDate: row.wktme5_start.length !== 0 ? handleDatetime3(row.wktme5_start[0]) + '~' + handleDatetime3(row.wktme5_start[1]) : '',
+        Duration: parseFloat(Duration.toFixed(2))
+      }
+      const res = await CapacityPlanningSetupAddUpdate({ capacitylist: [data] })
+      if (res.code === '200') {
+        await this.getDialogData()
+      }
 
+      // 濡傛灉鏃堕棿娈典簩鐨勫紑濮嬫椂闂村皬浜庢椂闂存涓�鐨勭粨鏉熸椂闂�  鍒欒繑鍥瀟rue,骞朵笖鎻愮ず鐢ㄦ埛淇濆瓨涓嶄簡
+      function calcTime(time1, time2) {
+        const temp1 = parseInt(time1.split(':')[0]) * 60 + parseInt(time1.split(':')[1])
+        const temp2 = parseInt(time2.split(':')[0]) * 60 + parseInt(time2.split(':')[1])
+        return temp2 < temp1
+      }
     },
-    CapacityPlanningSearch() {
+    async delRow(row) {
+      const res = await CapacityPlanningSetupDelete({ capsetupcode: row.code })
+      if (res.code === '200') {
+        await this.getDialogData()
+      }
+    },
+    async  CapacityPlanningSearch() {
 
     },
     handleRequest() {
       this.getCapacityPlanningSearch().then(res => {
         if (res.code === '200') {
           this.getWorkShopSelect()
-          this.getDeviceTypeSelect()
+          // this.getDeviceTypeSelect()
         }
       })
     },
@@ -567,7 +855,7 @@
       this.total = res.count
       this.tableData = res.data
       this.tableData.forEach(item => {
-        item.CaptPlanShopCalendarList = item.CaiptPlanShopCalendarList ? item.CaptPlanShopCalendarList : []
+        item.CaptPlanShopCalendarList = item.CaptPlanShopCalendarList ? item.CaptPlanShopCalendarList : []
       })
 
       return { code: res.code }
@@ -576,15 +864,21 @@
       const { data: res } = await WorkShopSelect()
       this.workshopArr = res
     },
-    async getDeviceTypeSelect() {
-      const { data: res } = await DeviceTypeSelect()
+    // async getDeviceTypeSelect() {
+    //   const { data: res } = await DeviceTypeSelect()
+    //   this.devicetypeArr = res
+    // },
+    async  getWhkspIsEqpSearch(val) {
+      this.form.devicetype = ''
+      const { data: res } = await WhkspIsEqpSearch({ wkshpcode: val })
       this.devicetypeArr = res
     },
     mrfaSearch(row, operation) {
-      console.log(row)
       this.operation = operation
       this.dialogVisible = true
-
+      this.tempObj = row
+      this.radioSelectedCode = row.CaptPlanWorkShiftCode
+      this.getDialogData()
       this.$nextTick(() => {
         this.$refs.tableDataDialogRef.doLayout()
       })
@@ -606,14 +900,6 @@
     search() {
       this.getCapacityPlanningSearch()
     },
-    // 瀵煎叆鎸夐挳
-    upload() {
-      this.shows = true
-      this.$refs.importPickerFunc.newDataFunc()
-    },
-    colos() {
-      this.shows = false
-    },
     // 閲嶇疆
     reset() {
       this.form.workshop = ''
@@ -624,54 +910,16 @@
     setting(operation) {
       this.operation = operation
       this.dialogVisible = true
-
+      this.getDialogData()
       this.$nextTick(() => {
         this.$refs.tableDataDialogRef.doLayout()
       })
     },
-    // 鏂板鎸夐挳
-    add(operation) {
-      this.operation = operation
-      this.dialogVisible = true
-    },
-    // 淇敼鎸夐挳
-    edit(operation, row) {
-      this.operation = operation
-      this.dialogVisible = true
-
-      this.$nextTick(() => {
-        this.dialogForm.OrgCode = row.org_code
-        this.dialogForm.OrgName = row.org_name
-        this.dialogForm.SupUnit = row.parent_id
-      })
-    },
-    // 鍒犻櫎鎸夐挳
-    async del(row) {
-      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
-        confirmButtonText: '纭畾',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        DeleteOrganization({ orgid: row.code }).then(res => {
-          if (res.code === '200') {
-            this.$message.success('鍒犻櫎鎴愬姛!')
-            if (this.form.page > 1 && this.tableData.length === 1) {
-              this.form.page--
-            }
-            this.getCapacityPlanningSearch()
-          }
-        })
-      }).catch(() => {
-        this.$message.info('宸插彇娑堝垹闄�')
-      })
-    },
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
-      this.dialogForm.OrgType = ''
-      this.dialogForm.OrgCode = ''
-      this.dialogForm.OrgName = ''
-      this.dialogForm.SupUnit = ''
-      this.$refs.dialogForm.clearValidate()
+      this.radioSelectedCode = ''
+      this.tempObj = {}
+      this.tableDataDialog = []
     },
     // 瀵硅瘽妗嗗彇娑�
     dialogVisibleCancel() {
@@ -679,7 +927,21 @@
     },
     // 瀵硅瘽妗嗙‘璁�
     dialogVisibleConfirm() {
-      this.dialogVisible = false
+      const data = {
+        wkshopcode: this.tempObj.CaptPlanWorkShopid,
+        capunitcode: this.tempObj.CaptPlanDeviceTypeid,
+        captplanid: this.tempObj.CaptPlanId ? this.tempObj.CaptPlanId : '',
+        capsetupcode: this.radioSelectedCode,
+        captplantype: this.tempObj.CaptPlanType
+      }
+      this.$store.state.app.buttonIsDisabled = true
+      CapacityPlanSubmit(data).then(res => {
+        if (res.code === '200') {
+          this.dialogVisible = false
+          this.$store.state.app.buttonIsDisabled = false
+          this.getCapacityPlanningSearch()
+        }
+      })
     },
     // 鑾峰彇椤甸潰楂樺害
     getHeight() {
@@ -828,9 +1090,22 @@
   }
 }
 </style>
-<style>
+<style lang="scss">
 
 .el-table .custom-row {
   background: #f8f8fa;
 }
+.table_only{
+  overflow: visible !important;
+  .el-table__body-wrapper{
+    overflow: visible !important
+  }
+}
+/*涓轰簡璁╅潰鏉垮湪瓒呭嚭鍖哄煙鍙樉绀�*/
+/*.el-table__body-wrapper{*/
+/*  overflow: visible !important*/
+/*}*/
+/*.table_only{*/
+/*overflow: visible !important*/
+/*}*/
 </style>

--
Gitblit v1.9.3