jbb 2 years ago
parent
commit
0db2b5dffc
2 changed files with 214 additions and 121 deletions
  1. 6 5
      src/views/oa/modules/SyCarryModal.vue
  2. 208 116
      src/views/oa/modules/SyCottonYarnModal.vue

+ 6 - 5
src/views/oa/modules/SyCarryModal.vue

@@ -71,13 +71,13 @@
         :columns="syCarryBTable.columns"
         :data-source="syCarryBTable.dataSource"
         :loading="syCarryBTable.loading"
-        :scroll="{x: 1800 }"
+        :scroll="{x: 1800,y:300 }"
         :pagination="false"
       >
         <!-- 日期 -->
          <span slot="orderDate" slot-scope="text, record,index">
                 <a-date-picker
-                    placeholder="请选择最终船期"
+                    placeholder="请选择"
                     v-model="record.orderDate"
                   />
           </span>
@@ -376,9 +376,9 @@
           if(item.orderDate!==''&&item.orderDate){
              item.orderDate = moment(item.orderDate).format('YYYY-MM-DD HH:mm:ss');
           }
-          if(!item.name){
-            item.name = ''
-          }
+          // if(!item.name){
+          //   item.name = ''
+          // }
         })
         obj.syCarryBList = this.syCarryBTable.dataSource
         if(this.defultMethods == 'add'){
@@ -418,6 +418,7 @@
          Hj+= Number(item.price)
        })
        this.formState.totalNum = Hj
+       this.$forceUpdate()
       }
       
     }

+ 208 - 116
src/views/oa/modules/SyCottonYarnModal.vue

@@ -1,51 +1,96 @@
 <template>
+<div class="reply" ref = "replyModal">
   <a-modal
     :title="title"
     width="85%"
     :visible="visible"
     :maskClosable="false"
     :confirmLoading="confirmLoading"
+    :getContainer ='()=>$refs.replyModal'
     @ok="handleOk"
     @cancel="handleCancel">
-    <a-spin :spinning="confirmLoading">
+     <div class="table-page-search-wrapper">
       <!-- 主表单区域 -->
-      <a-form :form="form">
-        
-        <a-row>
-          <a-col :span="12">
-            <a-form-item
-              :labelCol="labelCol"
-              :wrapperCol="wrapperCol"
-              label="名称">
-              <a-input placeholder="请输入名称" v-decorator="['name', {}]"/>
-            </a-form-item>
-          </a-col>
-          <a-col :span="12">
-            <a-form-item
-              :labelCol="labelCol"
-              :wrapperCol="wrapperCol"
-              label="编号">
-              <a-input placeholder="请输入编号" v-decorator="['code', {}]"/>
-            </a-form-item>
-          </a-col>
-        </a-row>
-        <a-row>
-          <a-col :span="24">
-            <a-form-item
-              :labelCol="labelCol"
-              :wrapperCol="wrapperCol"
-              label="备注">
-              <a-input type="textarea" placeholder="请输入备注" v-decorator="['demo', {}]"/>
-            </a-form-item>
-          </a-col>
-        </a-row>
-        
-      </a-form>
+       <a-form-model layout="inline" ref="form" :model="formState" :rules="validatorRules">
+          <a-row :gutter="24">
+            <a-col :md="8" :sm="8">
+              <a-form-model-item label="编号" prop="code">
+                <a-input   placeholder="请输入"  v-model="formState.code" />
+              </a-form-model-item>
+            </a-col>
+            <a-col :md="8" :sm="8">
+              <a-form-model-item label="名称"  prop="userId">
+                <a-input placeholder="请输入名称" v-model="formState.name"/>
+              </a-form-model-item>
+           </a-col>
+            <a-col :md="8" :sm="8">
+              <a-form-model-item label="合计"  prop="code">
+                 <a-input placeholder="请输入" v-model="formState.totalNum" readOnly/>
+               </a-form-model-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+              <a-col :md="24" :sm="8"> 
+               <a-form-model-item label="备注信息"  class="nresume" style="height:100px !important">
+                 <a-input type="textarea" placeholder="请输入" v-model="formState.demo"/>
+               </a-form-model-item>
+              </a-col>
+            </a-row>
+      </a-form-model>
 
       <!-- 子表单区域 -->
       <a-tabs v-model="activeKey" @change="handleChangeTabs">
         <a-tab-pane tab="棉纱" :key="refKeys[0]" :forceRender="true">
-          <j-editable-table
+          <a-button type="primary"  @click="addList">增行</a-button>
+          <a-table
+           bordered
+           :columns="syCottonYarnBTable.columns"
+           :data-source="syCottonYarnBTable.dataSource"
+           :loading="syCottonYarnBTable.loading"
+           :scroll="{x: 1800,y:300 }"
+           :pagination="false"
+          >
+          <!-- 日期 -->
+           <span slot="orderDate" slot-scope="text, record,index">
+                <a-date-picker
+                    placeholder="请选择"
+                    v-model="record.orderDate"
+                  />
+          </span>
+            <!-- 入库单号 -->
+          <span slot="receiptNo" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.receiptNo" />
+          </span>
+            <!-- 吨数 -->
+          <span slot="tonnage" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.tonnage" />
+          </span>
+           <!-- 柜子数量 -->
+          <span slot="cabinets" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.cabinets" />
+          </span>
+          <!-- 每吨纱价格 -->
+          <span slot="price" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.price" />
+          </span>
+          <!-- 集装箱号 -->
+          <span slot="containerNo" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.containerNo" />
+          </span>
+           <!-- 原因 -->
+          <span slot="reason" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.reason" />
+          </span>
+          <!-- 总价 -->
+          <span slot="totalPrice" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.totalPrice" />
+          </span>
+          <!-- 备注 -->
+          <span slot="demo" slot-scope="text, record, index">
+                  <a-input placeholder="请输入" v-model="record.demo" />
+          </span>
+          </a-table>
+          <!-- <j-editable-table
             :ref="refKeys[0]"
             :loading="syCottonYarnBTable.loading"
             :columns="syCottonYarnBTable.columns"
@@ -53,12 +98,13 @@
             :maxHeight="300"
             :rowNumber="true"
             :rowSelection="true"
-            :actionButton="true"/>
+            :actionButton="true"/> -->
         </a-tab-pane>
       </a-tabs>
 
-    </a-spin>
+     </div>
   </a-modal>
+</div>
 </template>
 
 <script>
@@ -67,6 +113,7 @@
   import pick from 'lodash.pick'
   import { FormTypes } from '@/utils/JEditableTableUtil'
   import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
+  import { putAction,postAction } from '@/api/manage'
 
   export default {
     name: 'SyCottonYarnModal',
@@ -79,81 +126,83 @@
         },
         refKeys: ['syCottonYarnB', ],
         activeKey: 'syCottonYarnB',
+        formState:{},
+        defultMethods:'add',
         // 搬运装卸费用-棉纱-子表
         syCottonYarnBTable: {
           loading: false,
           dataSource: [],
           columns: [
             {
-              title: '日期',
-              key: 'orderDate',
-              type: FormTypes.datetime,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '入库单号',
-              key: 'receiptNo',
-              type: FormTypes.input,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '吨数',
-              key: 'tonnage',
-              type: FormTypes.inputNumber,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '柜子数量',
-              key: 'cabinets',
-              type: FormTypes.inputNumber,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '每吨纱价格',
-              key: 'price',
-              type: FormTypes.inputNumber,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '集装箱号',
-              key: 'containerNo',
-              type: FormTypes.input,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '原因',
-              key: 'reason',
-              type: FormTypes.input,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '总价',
-              key: 'totalPrice',
-              type: FormTypes.inputNumber,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '签字',
-              key: 'jhyName',
-              type: FormTypes.input,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
-            {
-              title: '备注',
-              key: 'demo',
-              type: FormTypes.input,
-              defaultValue: '',
-              placeholder: '请输入${title}',
-            },
+            title: '日期',
+            align: "center",
+            dataIndex: 'orderDate',
+            width: '9%',
+            scopedSlots: { customRender: 'orderDate' },
+          },
+          {
+            title: '入库单号',
+            align: "center",
+            dataIndex: 'receiptNo',
+            width: '9%',
+            scopedSlots: { customRender: 'receiptNo' },
+          },
+          {
+            title: '吨数',
+            align: "center",
+            dataIndex: 'tonnage',
+            width: '9%',
+            scopedSlots: { customRender: 'tonnage' },
+          },
+          {
+            title: '柜子数量',
+            align: "center",
+            dataIndex: 'cabinets',
+            width: '9%',
+            scopedSlots: { customRender: 'cabinets' },
+          },
+          {
+            title: '每吨纱价格',
+            align: "center",
+            dataIndex: 'price',
+            width: '9%',
+            scopedSlots: { customRender: 'price' },
+          },
+           {
+            title: '集装箱号',
+            align: "center",
+            dataIndex: 'containerNo',
+            width: '9%',
+            scopedSlots: { customRender: 'containerNo' },
+          },
+          {
+            title: '原因',
+            align: "center",
+            dataIndex: 'reason',
+            width: '9%',
+            scopedSlots: { customRender: 'reason' },
+          },
+          {
+            title: '总价',
+            align: "center",
+            dataIndex: 'totalPrice',
+            width: '9%',
+            scopedSlots: { customRender: 'totalPrice' },
+          },
+          {
+            title: '签字',
+            align: "center",
+            dataIndex: 'jhyName',
+            width: '9%',
+            scopedSlots: { customRender: 'jhyName' },
+          },
+          {
+            title: '备注',
+            align: "center",
+            dataIndex: 'demo',
+            width: '9%',
+            scopedSlots: { customRender: 'demo' },
+          },
           ]
         },
         url: {
@@ -166,22 +215,25 @@
       }
     },
     methods: {
+      addList(){
+        this.syCottonYarnBTable.dataSource.push({})
+      },
  
       /** 调用完edit()方法之后会自动调用此方法 */
-      editAfter() {
-        this.$nextTick(() => {
-          this.form.setFieldsValue(pick(this.model, 'name', 'code', 'demo', ))
+      // editAfter() {
+      //   this.$nextTick(() => {
+      //     this.form.setFieldsValue(pick(this.model, 'name', 'code', 'demo', ))
           // 时间格式化
           // this.form.setFieldsValue({ ckTime: this.model.ckTime ? moment(this.model.ckTime) : null })
           // this.form.setFieldsValue({ rsxzTime: this.model.rsxzTime ? moment(this.model.rsxzTime) : null })
           // this.form.setFieldsValue({ cwjlTime: this.model.cwjlTime ? moment(this.model.cwjlTime) : null })
-        })
+        // })
         // 加载子表数据
-        if (this.model.id) {
-          let params = { id: this.model.id }
-          this.requestSubTableData(this.url.syCottonYarnB.list, params, this.syCottonYarnBTable)
-        }
-      },
+      //   if (this.model.id) {
+      //     let params = { id: this.model.id }
+      //     this.requestSubTableData(this.url.syCottonYarnB.list, params, this.syCottonYarnBTable)
+      //   }
+      // },
  
       /** 整理成formData */
       classifyIntoFormData(allValues) {
@@ -194,10 +246,50 @@
           ...main, // 展开
           syCottonYarnBList: allValues.tablesValue[0].values,
         }
-      }
+      },
+       //保存
+      handleOk(){
+        var obj = this.formState
+        this.syCottonYarnBTable.dataSource.map(item=>{
+          if(item.orderDate!==''&&item.orderDate){
+             item.orderDate = moment(item.orderDate).format('YYYY-MM-DD HH:mm:ss');
+          }
+        })
+        obj.syCottonYarnBTable = this.syCottonYarnBTable.dataSource
+        if(this.defultMethods == 'add'){
+         postAction(this.url.add, obj).then(res => {
+           debugger
+                    if (res.success) {
+                      debugger
+                      this.$message.success('新增成功')
+                      // this.handleCancel()
+                      // this.$emit('close')
+                    }else{
+                       this.$message.error(res.message);
+                    }
+                })
+        }else{
+          putAction(this.url.edit, obj).then((res) => {
+          if(res.success){
+            this.$message.success('编辑成功')
+            // this.handleCancel()
+            // this.$emit('close')
+          }else{
+            this.$message.warning(res.message)
+          }
+        })
+        }
+        
+      },
     }
   }
 </script>
 
-<style scoped>
+<style scoped lang="less">
+/deep/ .nresume .ant-input{
+  height: 100px !important;
+}
+/deep/ .td{
+  text-align:center;
+}
 </style>