Jelajahi Sumber

物料登记单新增,编辑,删除

jbb 2 tahun lalu
induk
melakukan
907b1d29b0

+ 36 - 0
src/api/oa/cd-material-registration.js

@@ -0,0 +1,36 @@
+import { getAction, deleteAction, putAction, postAction } from '@/api/manage'
+
+
+// 查询分页数据
+const managementList = (params) => getAction('/oa/syMaterial/list', params)
+
+// 新增
+const managementAdd = (params) => postAction('/oa/syMaterial/add', params)
+
+// 修改
+const managementEdit = (params) => putAction('/oa/syMaterial/edit', params)
+
+/**
+ * 删除
+ * @param {*} params {id:''}
+ */
+const enterpriseEDelete   = (params)=>deleteAction("/oa/syMaterial/deleteBatch",params);
+
+// 通过id查询B表
+const managementListB = (params) => getAction('/oa/syMaterial/querySyMaterialBByMainId', params)
+
+// 通过id查询C表
+const managementListC = (params) => getAction('/oa/syMaterial/querySyMaterialCByMainId', params)
+
+// 通过id查询
+const managementListA = (params) => getAction('/oa/syMaterial/queryById', params)
+
+export {
+    managementList,
+    managementAdd,
+    managementEdit,
+    enterpriseEDelete,
+    managementListA,
+    managementListB,
+    managementListC
+}

+ 111 - 27
src/views/system/MaterialRegistration.vue

@@ -15,7 +15,8 @@
               <a-date-picker
                style="width: 100%"
                placeholder="请选择购买日期"
-               v-model="queryParam.buyTime"
+               v-model="buyTime"
+                @change="onEndDateChange"
               />
             </a-form-item>
           </a-col>
@@ -82,7 +83,7 @@
       </a-table>
     </div>
     <!-- 新增框 -->
-    <add-material-registration ref='AddMaterialRegistration'></add-material-registration>
+    <add-material-registration ref='AddMaterialRegistration' @close="handleCl"></add-material-registration>
     <detail-material-registration ref="DetailMaterialRegistration"></detail-material-registration>
    </a-card>
    
@@ -93,19 +94,32 @@
   import {JeecgListMixin} from '@/mixins/JeecgListMixin'
   import AddMaterialRegistration from './modules/AddMaterialRegistration'
   import DetailMaterialRegistration from './modules/DetailMaterialRegistration'
+  import {
+    managementList,
+    managementAdd,
+    managementEdit,
+    enterpriseEDelete,
+    managementListA,
+    managementListB,
+    managementListC
+} from '@api/oa/cd-material-registration'
+import moment from 'moment'
+
 
   export default {
     name: "MaterialRegistration",
     mixins: [JeecgListMixin],
     components: {
     AddMaterialRegistration,
-    DetailMaterialRegistration
+    DetailMaterialRegistration,
+    moment
     },
     data() {
       return {
           queryParam:{   //查询条件
 
           },
+          buyTime:'',
         //   表头
         columns:[
             {
@@ -199,49 +213,119 @@
     methods: {
         // 查询
         searchQuery(){
-
+          this.getData()
         },
         //重置
         searchReset(){
           this.queryParam ={}
+          this.getData()
         },
         // 获取数据
         getData(){
-            // this.dataSource.push({
-            //   code:'1',
-            //   name:'2',
-            //   model:'1',
-            //   buyTime:'1',
-            //   buyNum:'1',
-            //   unit:'1',
-            //   amount:'1',
-            //   useId:'1',
-            //   type:'1',
-            //   supply:'1',
-            //   remarks:'1',
-            //   source:'1'
-            // })
+             this.$nextTick(() => {
+                managementList(this.queryParam).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                       this.dataSource =res.result.records
+                    }else{
+                       this.$message.error(res.message);
+                    }
+                })
+            })
         },
+         onEndDateChange(value){
+           this.queryParam.buyTime =moment(value).format('YYYY-MM-DD');
+         },
         // 删除
         handleDelete(){
-
+          debugger
+          var id = this.selectedRowKeys.toString()
+          enterpriseEDelete({ids:id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                      this.$message.success('删除成功');
+                      this.getData()
+                    }else{
+                       this.$message.error(res.message);
+                    }
+                })
         },
         // 添加
         handleAdd(){
           this.$refs.AddMaterialRegistration.visible = true
         },
         //编辑
-        handleEdit(record){
-           this.$refs.AddMaterialRegistration.visible = true
-            this.$refs.AddMaterialRegistration.defult = 'edit'
-            this.$refs.AddMaterialRegistration.formState = record
+      async  handleEdit(record){
+        await  managementListA({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                     this.$refs.AddMaterialRegistration.formState = res.result
+                     this.$refs.AddMaterialRegistration.buyTime = moment( res.result.buyTime)
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
+          await   managementListB({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                       res.result.map(item =>[
+                       item.state = '0'
+                     ])
+                     this.$refs.AddMaterialRegistration.List = res.result
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
+          await  managementListC({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                       res.result.map(item =>[
+                       item.state = '0'
+                     ])
+                     this.$refs.AddMaterialRegistration.List1 = res.result
+                     this.$refs.AddMaterialRegistration.visible = true
+                     this.$refs.AddMaterialRegistration.defult = 'edit'
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
         },
         //详情
-        handleDetail(record){
-           this.$refs.DetailMaterialRegistration.visible = true
-           this.$refs.DetailMaterialRegistration.formState = record
-
+      async  handleDetail(record){
+        await  managementListA({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                     this.$refs.DetailMaterialRegistration.formState = res.result
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
+          await   managementListB({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                     this.$refs.DetailMaterialRegistration.List = res.result
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
+          await  managementListC({id:record.id}).then(res => {
+                    // console.log('>>>>', this.queryParam)
+                    if (res.success) {
+                     this.$refs.DetailMaterialRegistration.List1 = res.result
+                     this.$refs.DetailMaterialRegistration.visible = true
+                      this.$refs.DetailMaterialRegistration.visible = true
+                    }else{
+                       this.$message.error(res.message);
+                    }
+            })
         },
+      onSelectChange(keys,rows){
+           this.selectedRowKeys = keys;
+            this.selectedRows = rows;
+         },
+       handleCl(){
+         this.getData()
+       }
     }
      
 

+ 333 - 8
src/views/system/modules/AddMaterialRegistration.vue

@@ -26,7 +26,7 @@
             <a-date-picker
             style="width: 100%"
             placeholder="请选择购买日期"
-            v-model="formState.buyTime"
+            v-model="buyTime"
           />
         </a-form-item>
         <a-form-item label="购买数量"  >
@@ -55,26 +55,223 @@
         </a-form-item>
       </a-form>
     </a-spin>
+    <a-card :bordered="false" >
+          <div class="purchase-order-table"  >
+            <div >
+               <h6 class="table-title" style="float: left">维修服务记录</h6>
+                <a-button @click="addList" type="primary" style="float: right;position: relative;z-index: 11" >新增</a-button>
+            </div>
+              <a-table
+                :columns="Columns"
+                :data-source="List"
+                bordered
+                :pagination="false"
+              >
+              <span slot="headCode" slot-scope="text, record">
+                 <span v-show="record.state=='0'">{{record.headCode}}</span>
+                 <a-input v-show="record.state=='1'" placeholder="请输入" v-model="record.headCode"/>
+              </span>
+              <span slot="infoDate" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.infoDate}}</span>
+                  <a-date-picker
+                     style="width: 100%"
+                     placeholder="请选择时间"
+                    v-model="record.infoDate"
+                    v-if="record.state=='1'"
+                   />
+              </span>
+              <span slot="items" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.items}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.items"/>
+              </span>
+              <span slot="cost" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.cost}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.cost"/>
+              </span>
+              <span slot="remarks" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.remarks}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.remarks"/>
+              </span>
+               <span slot="operation" slot-scope="text, record,index">
+                 <a @click="handleEdit(record,'1')">编辑</a>
+                 <a-divider type="vertical" />
+                 <a @click="handleDelete(index,'1')" style="color:red">删除</a>
+                 <a-divider type="vertical" v-if="record.state=='1'"/>
+                 <a @click="handleCl(record,'1')" style="color:red" v-if="record.state=='1'">取消</a>
+               </span>
+              </a-table>
+          </div>
+           <div class="purchase-order-table" >
+             <div>
+               <h6 class="table-title" style="float: left">领用记录</h6>
+                <a-button @click="addList1" type="primary" style="float: right;position: relative;z-index: 11" >新增</a-button>
+            </div>
+              <a-table
+                :columns="Columns1"
+                :data-source="List1"
+                bordered
+                :pagination="false"
+              >
+              <span slot="headCode" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.headCode}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.headCode"/>
+              </span>
+              <span slot="infoDate" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.useDate}}</span>
+                  <a-date-picker
+                     style="width: 100%"
+                     placeholder="请选择时间"
+                    v-model="record.useDate"
+                    v-if="record.state=='1'"
+                   />
+              </span>
+              <span slot="items" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.useId}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.useId"/>
+              </span>
+              <span slot="cost" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.returnDate}}</span>
+                 <a-date-picker
+                     style="width: 100%"
+                     placeholder="请选择时间"
+                    v-model="record.returnDate"
+                    v-if="record.state=='1'"
+                   />
+              </span>
+              <span slot="remarks" slot-scope="text, record">
+                 <span v-if="record.state=='0'">{{record.remarks}}</span>
+                 <a-input v-else placeholder="请输入" v-model="record.remarks"/>
+              </span>
+              <span slot="operation" slot-scope="text, record,index">
+                 <a @click="handleEdit(record,'2')">编辑</a>
+                 <a-divider type="vertical" />
+                 <a @click="handleDelete(index,'2')" style="color:red">删除</a>
+                  <a-divider type="vertical" v-if="record.state=='1'"/>
+                 <a @click="handleCl1(record)" style="color:red" v-if="record.state=='1'">取消</a>
+               </span>
+              </a-table>
+          </div>
+      </a-card>
 
   </a-modal>
 </template>
 
 <script>
-
+import {
+   managementList,
+    managementAdd,
+    managementEdit,
+    enterpriseEDelete
+} from '@api/oa/cd-material-registration'
+import moment from 'moment'
 
 export default {
     name: 'AddMaterialRegistration',
     components: {
-        
+        moment
     },
     data () {
         return {
             visible:false,
             defult:'add',
+            buyTime:'',
             formState:{
 
             },
             confirmLoading: false,
+             Columns:[
+            
+            {
+            title: '主要信息编号',
+            align: "center",
+            dataIndex: 'headCode',
+            width: 160,
+            scopedSlots: { customRender: 'headCode' },
+          },
+          {
+            title: '日期',
+            align: "center",
+            dataIndex: 'infoDate',
+            width: 180,
+            scopedSlots: { customRender: 'infoDate' },
+            
+          },
+          {
+            title: '维修项目',
+            align: "center",
+            dataIndex: 'items',
+            width: 180,
+            scopedSlots: { customRender: 'items' },
+          },
+          {
+            title: '费用',
+            align: "center",
+            dataIndex: 'cost',
+            width: 120,
+            scopedSlots: { customRender: 'cost' },
+          },
+          {
+            title: '备注',
+            align: "center",
+            dataIndex: 'remarks',
+            width: 120,
+            scopedSlots: { customRender: 'remarks' },
+          },
+          {
+            title: '操作',
+            align: "center",
+            dataIndex: 'operation',
+            scopedSlots: { customRender: 'operation' },
+            width: 180
+          },
+        ],
+         Columns1:[
+            {
+            title: '主要信息编号',
+            align: "center",
+            dataIndex: 'headCode',
+            width: 160,
+            scopedSlots: { customRender: 'headCode' },
+          },
+          {
+            title: '领用日期',
+            align: "center",
+            dataIndex: 'useDate',
+            width: 180,
+            scopedSlots: { customRender: 'infoDate' },
+          },
+          {
+            title: '领用人',
+            align: "center",
+            dataIndex: 'useId',
+            width: 160,
+            scopedSlots: { customRender: 'items' },
+          },
+          {
+            title: '归还日期',
+            align: "center",
+            dataIndex: 'returnDate',
+            width: 180,
+            scopedSlots: { customRender: 'cost' },
+          },
+          {
+            title: '备注',
+            align: "center",
+            dataIndex: 'remarks',
+            width: 120,
+            scopedSlots: { customRender: 'remarks' },
+          },
+          {
+            title: '操作',
+            align: "center",
+            dataIndex: 'operation',
+            scopedSlots: { customRender: 'operation' },
+            width: 180
+          },
+        ],
+        List:[],
+        List1:[],
+        
         }
     },
     created () {
@@ -87,18 +284,118 @@ export default {
      close(){
        this.visible = false
        this.formState={}
-       this.defult='add'
+       this.defult='add',
+       this.List =[],
+       this.List1=[],
+       this.buyTime = '',
+       this.defult ='add',
+       this.$emit('close')
      },
     handleSubmit(){
-      
+       this.$nextTick(() => {
+        this.formState.buyTime = moment(this.buyTime).format('YYYY-MM-DD');
+        var newObj = this.formState
+        newObj.syMaterialBList = this.List
+        newObj.syMaterialCList  =this.List1
+        newObj.syMaterialBList.map(item =>{
+          item.infoDate = moment(item.infoDate).format('YYYY-MM-DD');
+        })
+        newObj.syMaterialCList.map(item=>{
+          item.useDate = moment(item.useDate).format('YYYY-MM-DD');
+          item.returnDate = moment(item.returnDate).format('YYYY-MM-DD');
+        })
+        if(this.defult == 'add'){
+           managementAdd(newObj).then(res => {
+                    if (res.success) {
+                       this.$message.success('新增成功');
+                       this.close()
+                       this.$emit('close')
+                    }else{
+                      this.$message.error(res.message);
+                    }
+            })
+        }else {
+          managementEdit(newObj).then(res => {
+                    if (res.success) {
+                      this.$message.success('编辑成功');
+                       this.close()
+                    }else{
+                      this.$message.error(res.message);
+                       this.$message.error(res.message);
+                    }
+            })
+        }
+                
+               
+      })
+    },
+       handleEdit(record,data){
+        record.state = '1'
+        record.default = 'edit'
+        if(data == '1'){
+          record.infoDate = moment(record.infoDate)
+        }else{
+          record.useDate = moment(record.useDate)
+          record.returnDate = moment(record.returnDate)
+        }
+        
+        this.$forceUpdate()
+
+  },
+  addList(){
+        var line ={
+        headCode:'',
+        infoDate:'',
+        items:'',
+        cost:'',
+        remarks:'',
+        state:'1',
+        default:'add'
+      }
+      this.List.unshift(line)
+  },
+  addList1(){
+        var line ={
+        headCode:'',
+        infoDate:'',
+        items:'',
+        cost:'',
+        remarks:'',
+        state:'1',
+        default:'add'
+      }
+      this.List1.unshift(line)
+  },
+  handleCl(record){
+    if(record.default == 'add'){
+      this.List.shift()
+    }else if(record.default == 'edit'){
+      record.state ='0'
     }
+  },
+  handleCl1(record){
+    if(record.default == 'add'){
+      this.List1.shift()
+    }else if(record.default == 'edit'){
+      record.state ='0'
+      this.$forceUpdate()
     }
+  },
+  handleDelete(index,data){
+     if(data == '1'){
+          this.List.splice(index, 1);
+        }else{
+          this.List1.splice(index, 1);
+        }
+    
+  }
+}
 }
 </script>
 
 <style scoped lang="less">
 /deep/.ant-form{
-    display: flex;
+    display: flex !important;
     width: 100%;
     flex-wrap: wrap;
     justify-content: center;
@@ -106,11 +403,39 @@ export default {
 
 /deep/ .ant-form-item{
     display: flex;
-    width: 45%;
+    width: 24%;
     justify-content: center;
 }
 /deep/ .ant-form-item-label{
-  width: 20%;
+  width: 35%;
+}
+.table-title {
+  margin: 0;
+  border: 1px solid #e8e8e8;
+  background-color: #f2f2f2;
+  border-top-right-radius: 16px;
+  border-bottom: none;
+  font-size: 16px;
+  width: 160px;
+  height: 40px;
+  line-height: 40px;
+  text-align: center;
+}
+.purchase-order-table{
+  margin-bottom: 10px;
+}
+
+/deep/ .ant-card-body{
+      padding: 0px 32px !important;
+}
+/deep/ .ant-divider-horizontal{
+  margin: 13px 0;
+}
+/deep/ .ant-card-body{
+      padding: 0px 32px !important;
+}
+/deep/ .ant-divider-horizontal{
+  margin: 13px 0;
 }
 
 

+ 6 - 90
src/views/system/modules/DetailMaterialRegistration.vue

@@ -57,7 +57,6 @@
           <div class="purchase-order-table"  >
             <div >
                <h6 class="table-title" style="float: left">维修服务记录</h6>
-                <a-button @click="addList" type="primary" style="float: right;position: relative;z-index: 11" >新增</a-button>
             </div>
               <a-table
                 :columns="Columns"
@@ -65,44 +64,12 @@
                 bordered
                 :pagination="false"
               >
-              <span slot="headCode" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.headCode}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.headCode"/>
-              </span>
-              <span slot="infoDate" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.infoDate}}</span>
-                  <a-date-picker
-                     style="width: 100%"
-                     placeholder="请选择时间"
-                    v-model="record.infoDate"
-                    v-if="record.state=='1'"
-                   />
-              </span>
-              <span slot="items" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.items}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.items"/>
-              </span>
-              <span slot="cost" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.cost}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.cost"/>
-              </span>
-              <span slot="remarks" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.remarks}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.remarks"/>
-              </span>
-               <span slot="operation" slot-scope="text, record">
-                 <a @click="handleEdit(record)">编辑</a>
-                 <a-divider type="vertical" />
-                 <a @click="handleDetail(record)" style="color:red">删除</a>
-                 <a-divider type="vertical" v-if="record.state=='1'"/>
-                 <a @click="handleCl(record)" style="color:red" v-if="record.state=='1'">取消</a>
-               </span>
+              
               </a-table>
           </div>
            <div class="purchase-order-table" >
              <div>
                <h6 class="table-title" style="float: left">领用记录</h6>
-                <a-button @click="addList1" type="primary" style="float: right;position: relative;z-index: 11" >新增</a-button>
             </div>
               <a-table
                 :columns="Columns1"
@@ -110,43 +77,7 @@
                 bordered
                 :pagination="false"
               >
-              <span slot="headCode" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.headCode}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.headCode"/>
-              </span>
-              <span slot="infoDate" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.infoDate}}</span>
-                  <a-date-picker
-                     style="width: 100%"
-                     placeholder="请选择时间"
-                    v-model="record.infoDate"
-                    v-if="record.state=='1'"
-                   />
-              </span>
-              <span slot="items" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.items}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.items"/>
-              </span>
-              <span slot="cost" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.cost}}</span>
-                 <a-date-picker
-                     style="width: 100%"
-                     placeholder="请选择时间"
-                    v-model="record.cost"
-                    v-if="record.state=='1'"
-                   />
-              </span>
-              <span slot="remarks" slot-scope="text, record">
-                 <span v-if="record.state=='0'">{{record.remarks}}</span>
-                 <a-input v-else placeholder="请输入" v-model="record.remarks"/>
-              </span>
-              <span slot="operation" slot-scope="text, record">
-                 <a @click="handleEdit(record)">编辑</a>
-                 <a-divider type="vertical" />
-                 <a @click="handleDetail(record)" style="color:red">删除</a>
-                  <a-divider type="vertical" v-if="record.state=='1'"/>
-                 <a @click="handleCl1(record)" style="color:red" v-if="record.state=='1'">取消</a>
-               </span>
+             
               </a-table>
           </div>
       </a-card>
@@ -208,17 +139,9 @@ export default {
             width: 120,
             scopedSlots: { customRender: 'remarks' },
           },
-          {
-            title: '操作',
-            align: "center",
-            dataIndex: 'operation',
-            scopedSlots: { customRender: 'operation' },
-            width: 180
-          },
         ],
          Columns1:[
-            
-            {
+           {
             title: '主要信息编号',
             align: "center",
             dataIndex: 'headCode',
@@ -228,21 +151,21 @@ export default {
           {
             title: '领用日期',
             align: "center",
-            dataIndex: 'infoDate',
+            dataIndex: 'useDate',
             width: 180,
             scopedSlots: { customRender: 'infoDate' },
           },
           {
             title: '领用人',
             align: "center",
-            dataIndex: 'items',
+            dataIndex: 'useId',
             width: 160,
             scopedSlots: { customRender: 'items' },
           },
           {
             title: '归还日期',
             align: "center",
-            dataIndex: 'cost',
+            dataIndex: 'returnDate',
             width: 180,
             scopedSlots: { customRender: 'cost' },
           },
@@ -253,13 +176,6 @@ export default {
             width: 120,
             scopedSlots: { customRender: 'remarks' },
           },
-          {
-            title: '操作',
-            align: "center",
-            dataIndex: 'operation',
-            scopedSlots: { customRender: 'operation' },
-            width: 180
-          },
         ],
         List:[],
         List1:[],