Procházet zdrojové kódy

调整合同添加工具,工具借用管理

qymljy před 2 roky
rodič
revize
4bdac25863

+ 116 - 2
src/HDrpManagement/contractManage/components/toolList/toolList.vue

@@ -4,6 +4,20 @@
       <div class="flex-align-center" style="margin-bottom:10px">
         <el-input size="small" style="width:200px;margin-right:10px" v-model="params.content.where.condition" placeholder="产品编号、产品名称、材质、品牌" @clear="listData(params.content.pageNumber = 1)" @keyup.native.enter="listData(params.content.pageNumber = 1)" clearable></el-input>
         <slot name="addProduct"/>
+        <addTool ref="addTool" :params="paramsAdd" :tablecolsAdd="tablecolsAdd" title="添加" @addSuccess="addTools"
+                 @addProduct="addTool" @uploadData="uploadData" @closeDrawer="listData();$emit('onSuccess')"
+                 v-if="tool.checkAuth($route.name,'toolListManage') && data.status == '新建' && isLeader" class="inline-16"
+        ></addTool>
+        <uploadAllData
+            v-if="tool.checkAuth($route.name,'toolListManage') && data.status == '新建' && isLeader"
+            class="inline-16"
+            :total="total"
+            @onSuccess="listData();$emit('onSuccess')"
+            @handlePullApi="handlePullApi"
+            @handleDelApi="handleDelApi"
+            idName="sa_contract_itemsid"
+            type="del"
+        ></uploadAllData>
       </div>
       <tableLayout :layout="tablecols" :data="list" :opwidth="200" height="calc(100vh - 550px)" :custom="true" fixedName="operation qty marketprice discountrate price countPrice" >
         <template v-slot:customcol="scope">
@@ -71,16 +85,19 @@
 // import edit from './editProduct'
 import addProduct from './addTool'
 import previewImage from '@/components/previewImage/index'
+import addTool from '@/template/addTool/index'
+import uploadAllData from '@/components/uploadAllData/index'
 export default {
-  components: {addProduct,previewImage},
+  components: {addProduct,previewImage,addTool,uploadAllData},
   name: '',
+  props:["data","isLeader"],
   data() {
     return {
       list:[],
       params: {
           "id": 20221122165302,
           "content": {
-              "sa_contractid": '',
+              "sa_contractid": this.$route.query.id,
               "pageNumber": 1,
               "pageSize": 100,
               "where": {
@@ -88,12 +105,25 @@ export default {
               }
           },
       },
+      paramsAdd:{
+        "id": 20221124093602,
+        "content": {
+          "sa_contractid": this.$route.query.id,
+          "pageNumber": 1,
+          "pageSize": 100,
+          "where": {
+            "condition": "",
+            "istool":1//是否是工具
+          }
+        },
+      },
       form: {
         qty:'',
         discountrate:'',
         price:'',
       },
       tablecols:[],
+      tablecolsAdd:[],
       total:0,
       editIndex:'',
       totalPrice:0,
@@ -107,6 +137,7 @@ export default {
   created () {
     if (this.$route.query.id) this.listData()
     this.tablecols = this.tool.tabelCol(this.$route.name).toolTable.tablecols
+    this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols
   },
   methods: {
     async listData(){
@@ -172,6 +203,89 @@ export default {
       this.params.content.pageNumber = val
       this.listData()
     },
+    /*批量添加工具*/
+    async addTools(data){
+      let item = data.map(item => {
+        return {
+          "itemid": item.itemid,
+          "price": item.marketprice,
+          "qty": 1,
+          "marketprice":item.marketprice,
+          "type":'指定单价'
+        }
+      })
+      let res = await this.$api.requested({
+        "id": 20221123164402,
+        "content": {
+          "sa_contractid": this.$route.query.id,
+          "items": item
+        },
+      })
+      this.tool.showMessage(res,() => {
+        this.listData()
+        this.$refs.addTool.listData()
+        this.$emit('onSuccess')
+      })
+    },
+    /*单独添加*/
+    async addTool(data){
+      let res = await this.$api.requested({
+        "id": 20221123164402,
+        "content": {
+          "sa_contractid": this.$route.query.id,
+          "items": [
+            {
+              "itemid": data.itemid,
+              "price": data.marketprice,
+              "qty": 1,
+              "marketprice":data.marketprice,
+              "type":'指定单价'
+            }
+          ]
+        },
+      })
+      this.tool.showMessage(res,() => {
+        this.listData()
+        this.$refs.addTool.listData()
+        this.$emit('onSuccess')
+      })
+    },
+    /*一键添加*/
+    uploadData (uploadApi,data) {
+      uploadApi.id = 20221123164402
+      uploadApi.content = {
+        "sa_contractid": this.$route.query.id, //订单ID
+        "items": data.map(e=>{
+          return {
+            "itemid": e.itemid,
+            "price": e.marketprice,
+            "qty": 1,
+            "marketprice":e.marketprice,
+            "type":'指定单价'
+          }
+        })
+      }
+      this.listData()
+      this.$refs.addTool.listData()
+      this.$emit('onSuccess')
+    },
+    /*拉取数据*/
+    handlePullApi (pullApi) {
+      pullApi.content = JSON.parse(JSON.stringify(this.params.content))
+      pullApi.id = 20221122165302
+      pullApi.content.sa_contractid = this.$route.query.id
+    },
+    /*一键删除*/
+    handleDelApi (delApi,data) {
+      delApi.id = 20221123164502
+      delApi.content = {
+        "sa_contractid":this.$route.query.id,
+        "sa_contract_itemsids":data,
+        "pageNumber":0,
+        "pageSize":0
+      }
+      this.listData()
+    },
   },
 };
 </script>

+ 2 - 2
src/HDrpManagement/contractManage/modules/detail.vue

@@ -71,8 +71,8 @@
           </template>
         </productDetailList>
         <!--工具清单-->
-        <toolList ref="toolList" v-if="mainData.type == '工具借用'" @priceChange="queryMainData">
-          <addTool v-if="tool.checkAuth($route.name,'toolListManage')" :disabled="mainData.status != '新建' || !isLeader" slot="addProduct" @onSuccess="$refs.toolList.listData()"/>
+        <toolList :data="mainData" :isLeader="isLeader" ref="toolList" v-if="mainData.type == '工具借用'" @priceChange="queryMainData">
+<!--          <addTool v-if="tool.checkAuth($route.name,'toolListManage')" :disabled="mainData.status != '新建' || !isLeader" slot="addProduct" @onSuccess="$refs.toolList.listData()"/>-->
           <template v-slot:edit="scope">
             <el-button 
               v-if="tool.checkAuth($route.name,'toolListManage')"

+ 119 - 4
src/HDrpManagement/toolBorrowingMag/detail/tabs/toolList.vue

@@ -1,6 +1,19 @@
 <template>
   <div>
-    <addProduct class="inline-16" :data="data" @onConfirm="listData()"></addProduct>
+<!--    <addProduct class="inline-16" :data="data" @onConfirm="listData()"></addProduct>-->
+    <addTool ref="addTool" :params="paramsAdd" :tablecolsAdd="tablecolsAdd" title="添加" @addSuccess="addTools"
+             @addProduct="addTool" @uploadData="uploadData" @closeDrawer="listData();$emit('onSuccess')"
+             class="inline-16"
+    ></addTool>
+    <uploadAllData
+        class="inline-16"
+        :total="total"
+        @onSuccess="listData();$emit('onSuccess')"
+        @handlePullApi="handlePullApi"
+        @handleDelApi="handleDelApi"
+        idName="sa_orderitemsid"
+        type="del"
+    ></uploadAllData>
     <el-button v-if="tool.checkAuth($route.name,'adddispatch')" size="small" type="primary" @click="adddispatch">一键发货</el-button>
     <el-table
       ref="multipleTable"
@@ -183,17 +196,19 @@
 
 <script>
 import addProduct from '@/template/toolBorrowingCanUseProduct/index.vue'
-
+import addTool from '@/template/addTool/index'
+import uploadAllData from '@/components/uploadAllData/index'
 export default {
   props:['data','type'],
   data () {
     return {
       dataRefresh:true,
       tableData:[],
+      tablecolsAdd:[],
       param:{
         "id": 20230116104102,
         "content": {
-          "sa_orderid": 0, //订单ID
+          "sa_orderid": this.$route.query.id, //订单ID
           "pageNumber": 1,
           "pageSize": 9999,
           "where": {
@@ -201,6 +216,17 @@ export default {
           }
         },
       },
+      paramsAdd:{
+        "id": 20230116111602,
+        "content": {
+          "sa_orderid": this.$route.query.id,
+          "pageNumber": 1,
+          "pageSize": 100,
+          "where": {
+            "condition": ""
+          }
+        },
+      },
       pickerOptions: {
         disabledDate(time) {
           return time.getTime() < (Date.now() - 24 * 3600 * 1000);
@@ -214,7 +240,7 @@ export default {
     }
   },
   components:{
-    addProduct
+    addProduct,addTool,uploadAllData
   },
   methods:{
     async listData () {
@@ -350,9 +376,98 @@ export default {
         this.$router.replace({path:'/dispatchdetail',query:{id:res.data.sa_dispatchid,rowindex:res.data.rowindex}})
       })
     },
+    /*批量添加工具*/
+    async addTools(data){
+      let item = data.map(item => {
+        return {
+          sa_orderitemsid:0,
+          itemid:item.itemid,
+          qty:item.orderminqty,
+          needdate:item.deliverydate
+        }
+      })
+      let res = await this.$api.requested({
+        "id": 20221109093602,
+        "content": {
+          "sa_orderid": this.$route.query.id, //订单ID
+          "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
+          "type": "工具借用单", //订单类型
+          "items": item
+        },
+      })
+      this.tool.showMessage(res,() => {
+        this.listData()
+        this.$refs.addTool.listData()
+        this.$emit('onSuccess')
+      })
+    },
+    /*单独添加*/
+    async addTool(data){
+      let res = await this.$api.requested({
+        "id": 20221109093602,
+        "content": {
+          "sa_orderid": this.$route.query.id, //订单ID
+          "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
+          "type": "工具借用单", //订单类型
+          "items": [
+            {
+              sa_orderitemsid:0,
+              itemid:data.itemid,
+              qty:data.orderminqty,
+              needdate:data.deliverydate
+            }
+          ]
+        },
+      })
+      this.tool.showMessage(res,() => {
+        this.listData()
+        this.$refs.addTool.listData()
+        this.$emit('onSuccess')
+      })
+    },
+    /*一键添加*/
+    uploadData (uploadApi,data) {
+      uploadApi.id = 20221109093602
+      uploadApi.content = {
+        "sa_orderid": this.$route.query.id, //订单ID
+        "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
+        "type": "工具借用单", //订单类型
+        "items": data.map(e=>{
+          return {
+            sa_orderitemsid:0,
+            itemid:e.itemid,
+            qty:e.orderminqty,
+            needdate:e.deliverydate
+          }
+        })
+      }
+      this.listData()
+      this.$refs.addTool.listData()
+      this.$emit('onSuccess')
+    },
+    /*拉取数据*/
+    handlePullApi (pullApi) {
+      pullApi.content = JSON.parse(JSON.stringify(this.param.content))
+      pullApi.id = 20230116104102
+      pullApi.content.sa_orderid = this.$route.query.id
+    },
+    /*一键删除*/
+    handleDelApi (delApi,data) {
+      delApi.id = 20221109093702
+      delApi.content = {
+        "sa_orderid":this.$route.query.id,
+        "sa_orderitemsids": data,
+        "pageNumber":0,
+        "pageSize":0
+      }
+      this.listData()
+    },
   },
   mounted () {
     this.listData()
+  },
+  created() {
+    this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols
   }
 }
 

+ 1 - 1
src/components/uploadAllData/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <el-button type="primary" size="small" class="inline-16" @click="allProduct" v-if="type=='upload'">一 键 选 择</el-button>
+    <el-button type="primary" size="small" class="inline-16" @click="allProduct" v-if="type=='upload'">一 键 全 选</el-button>
     <el-button type="primary" size="small" class="inline-16" @click="allProduct" v-else>一 键 删 除</el-button>
     <el-dialog
       title=""

+ 13 - 5
src/template/addProduct/index.vue

@@ -11,7 +11,7 @@
         @close="onClose">
       <div class="drawer__panel">
         <div class="flex-between">
-          <el-select v-model="sa_brandid" placeholder="选择品牌" size="small" clearable class="inline-24" @change="brandChange" :disabled="querySa_brandid > 0">
+          <el-select v-model="sa_brandid" placeholder="选择品牌" size="small"  clearable class="inline-24" @change="brandChange" :disabled="querySa_brandid > 0">
             <el-option
                 v-for="item in options.brands"
                 :key="item.sa_brandid"
@@ -62,8 +62,8 @@
           <el-input  style="width:200px;" placeholder="规格" :suffix-icon="params.content.where.spec?params.content.where.spec.length > 0?'':'':'el-icon-search'" v-model="params.content.where.spec" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
           </el-input>
         </div>
-        <div class="top-margin">
-          <tableTemp :data="list" :layout="tablecolsAdd" :opwidth="200" :custom="true" height="calc(100vh - 370px)" @checkboxCallBack="checkboxCallBack">
+        <div >
+          <tableTemp :data="list" :layout="tablecolsAdd" :opwidth="200" :custom="true" height="calc(100vh - 370px)" @checkboxCallBack="checkboxCallBack" fixedName="operation">
             <template v-slot:customcol="scope">
               <p >{{scope.column.data[scope.column.columnname]}}</p>
             </template>
@@ -250,9 +250,17 @@ export default {
 <style scoped>
   .top-margin{
     margin-top: 20px;
-
   }
   .bottom-margin{
-    margin-bottom: 10px;
+    margin-bottom: 20px;
+  }
+ /deep/ input::-webkit-input-placeholder {
+    color: #58585d;
+  }
+  /deep/ input::-moz-input-placeholder {
+    color: #58585d;
+  }
+  /deep/ input::-ms-input-placeholder {
+    color: #58585d;
   }
 </style>

+ 3 - 3
src/template/addProduct/table.vue

@@ -1,13 +1,13 @@
 <template>
   <div>
-    <el-table ref="table" @selection-change="selectionChange" :row-class-name="tableClassName" highlight-current-row :data="data"  size="mini" :height="height" @row-click="rowClick" style="width:100%;min-height:300px"  border>
+    <el-table ref="table" @selection-change="selectionChange" :header-cell-style="{height:'40px','color':'#333333'}" :row-class-name="tableClassName" highlight-current-row :data="data"  size="mini" :height="height" @row-click="rowClick" style="width:100%;min-height:300px;"  border >
       <el-table-column
           type="selection"
-          width="55"  >
+          width="55"  fixed>
       </el-table-column>
       <el-table-column v-for="col in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :width="width && col.width === 0 ? 150 : col.width" :fixed="fixedName ? fixedName.indexOf(col.columnname)!= -1?'right':false : false">
         <template slot-scope="scope">
-          <div class="table-panel">
+          <div class="table-panel" style="color: #333333">
             <!-- 自定义表格显示内容 -->
             <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
             <!-- 否则就是默认 -->

+ 161 - 0
src/template/addTool/index.vue

@@ -0,0 +1,161 @@
+<template>
+  <div>
+    <el-button size="small" type="primary" @click="onShow" >{{title}}</el-button>
+    <el-drawer
+        title="添加工具"
+        :visible.sync="dialogFormVisible"
+        size="90%"
+        direction="rtl"
+        :show-close="false"
+        append-to-body
+        @close="onClose">
+      <div class="drawer__panel">
+        <div >
+          <uploadAllData
+              class="inline-16"
+              :total="total"
+              @handlePullApi="handlePullApi"
+              @handleUploadApi="handleUploadApi"
+              @onSuccess="onSuccess"
+          ></uploadAllData>
+          <el-button :disabled="items.length === 0" :type="items.length > 0?'primary':''" size="small" class="inline-24 bottom-margin" @click="batchAdd">添加选中商品</el-button>
+          <el-input  style="width:200px;" placeholder="商品名称/编码/品号" :suffix-icon="params.content.where.condition?params.content.where.condition.length > 0?'':'':'el-icon-search'" v-model="params.content.where.condition" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="input-with-select inline-24 layout_search__panel bottom-margin" clearable>
+          </el-input>
+          <el-input  style="width:200px;" placeholder="型号" :suffix-icon="params.content.where.model?params.content.where.model.length > 0?'':'':'el-icon-search'" v-model="params.content.where.model" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
+          </el-input>
+          <el-input  style="width:200px;" placeholder="规格" :suffix-icon="params.content.where.spec?params.content.where.spec.length > 0?'':'':'el-icon-search'" v-model="params.content.where.spec" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
+          </el-input>
+        </div>
+        <div >
+          <tableTemp :data="list" :layout="tablecolsAdd" :opwidth="200" :custom="true" height="calc(100vh - 370px)" @checkboxCallBack="checkboxCallBack" fixedName="operation">
+            <template v-slot:customcol="scope">
+              <p >{{scope.column.data[scope.column.columnname]}}</p>
+            </template>
+            <template v-slot:opreation="scope">
+              <el-button type="text" size="mini" @click="addProduct(scope)">添 加</el-button>
+            </template>
+          </tableTemp>
+          <div  class="container normal-panel" style="text-align:right">
+            <el-pagination
+                background
+                @size-change="handleSizeChange"
+                @current-change="handleCurrentChange"
+                :current-page="params.content.pageNumber"
+                :page-sizes="[20, 50, 100, 200]"
+                :page-size="100"
+                layout="total,sizes, prev, pager, next, jumper"
+                :total="total">
+            </el-pagination>
+          </div>
+        </div>
+      </div>
+    </el-drawer>
+  </div>
+</template>
+
+<script>
+import tableTemp from './table'
+import uploadAllData from '@/components/uploadAllData/index'
+
+export default {
+  name: "index",
+  props:["data","tradefield","discountrate","params","title","tablecolsAdd","sa_projectid","querySa_brandid"],
+  components:{tableTemp,uploadAllData},
+  data(){
+    return {
+      dialogFormVisible:false,
+      sa_brandid:'',
+      itemclassid:'',
+      itemstandard:'',
+      itemmaterial:'',
+      list:[],
+      total:0,
+      options:{
+        brands:[],
+        itemclass:[],
+        itemstandards:[],
+        itemmaterials:[]
+      },
+      items:[]
+    }
+  },
+  methods:{
+    onShow(){
+      this.dialogFormVisible = true
+      this.listData()
+    },
+    /*可添加商品*/
+    async listData(){
+      const res = await this.$api.requested(this.params)
+      this.list = res.data
+      this.total = res.total
+    },
+    /*拉取数据*/
+    handlePullApi (pullApi) {
+      pullApi.content = JSON.parse(JSON.stringify(this.params.content))
+      pullApi.id = this.params.id
+      /*pullApi.content.sa_projectid = this.$route.query.id*/
+    },
+    /*上传数据*/
+    handleUploadApi (uploadApi,data) {
+      this.$emit('uploadData',uploadApi,data)
+    },
+    /*勾选*/
+    checkboxCallBack(val){
+      this.items = val
+    },
+    /*批量添加*/
+    batchAdd(){
+      console.log(this.items,'item')
+      this.$emit('addSuccess',this.items)
+    },
+    /*添加商品*/
+    addProduct(val){
+      console.log(val,'添加商品')
+      this.items = val
+      this.$emit('addProduct',this.items.data)
+    },
+    onSuccess () {
+      console.log('成功')
+      this.listData()
+    },
+    onClose(){
+      this.dialogFormVisible = false
+      this.$emit("closeDrawer")
+    },
+    handleSizeChange(val) {
+      // console.log(`每页 ${val} 条`);
+      this.params.content.pageSize = val
+      this.listData()
+    },
+    handleCurrentChange(val) {
+      // console.log(`当前页: ${val}`);
+      this.params.content.pageNumber = val
+      this.listData()
+    },
+  },
+  mounted() {
+  },
+  created() {
+
+  }
+}
+</script>
+
+<style scoped>
+  .top-margin{
+    margin-top: 20px;
+  }
+  .bottom-margin{
+    margin-bottom: 20px;
+  }
+ /deep/ input::-webkit-input-placeholder {
+    color: #58585d;
+  }
+  /deep/ input::-moz-input-placeholder {
+    color: #58585d;
+  }
+  /deep/ input::-ms-input-placeholder {
+    color: #58585d;
+  }
+</style>

+ 72 - 0
src/template/addTool/table.vue

@@ -0,0 +1,72 @@
+<template>
+  <div>
+    <el-table ref="table" @selection-change="selectionChange" :header-cell-style="{height:'40px','color':'#333333'}" :row-class-name="tableClassName" highlight-current-row :data="data"  size="mini" :height="height" @row-click="rowClick" style="width:100%;min-height:300px;"  border >
+      <el-table-column
+          type="selection"
+          width="55"  fixed>
+      </el-table-column>
+      <el-table-column v-for="col in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :width="width && col.width === 0 ? 150 : col.width" :fixed="fixedName ? fixedName.indexOf(col.columnname)!= -1?'right':false : false">
+        <template slot-scope="scope">
+          <div class="table-panel" style="color: #333333">
+            <!-- 自定义表格显示内容 -->
+            <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
+            <!-- 否则就是默认 -->
+            <span v-else>{{scope.row[col.columnname]}}</span>
+            <!-- 操作结构内容 -->
+            <slot v-if="col.columnname === 'operation'" name="opreation" :data="scope.row"></slot>
+          </div>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import {mapGetters} from "vuex"
+export default {
+  /*
+    layout:表结构数据;
+    data:表渲染数据;
+    custom:是否启用自定义结构;
+    opwidth:操作列宽度
+  */
+  props:['layout','data','custom','height','checkbox','height','fixedName','width'],
+  data () {
+    return {
+      list:[],
+    }
+  },
+  computed:{
+    ...mapGetters({
+      loading:'loading'
+    })
+  },
+  methods:{
+    rowClick (row) {
+      console.log(row,'勾选')
+      this.$emit('rowClick',row)
+    },
+    tableClassName ({row,rowIndex}) {
+      row.index = rowIndex
+    },
+    selectionChange(val) {
+      this.$emit('checkboxCallBack',val)
+    },
+    isCheck(row,rowIndex) {
+      if (!row.status) return true
+      if(row.status == '待跟进' || row.status == '跟进中' || row.projectnum) {
+        return true
+      } else {
+        return false
+      }
+    },
+
+  },
+  mounted () {
+    // this.listData()
+  }
+}
+
+</script>
+<style>
+</style>