123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <div>
- <addProject ref="addProject" :param="paramProject" class="inline-16" @add="addProject" @adds="addProjects"></addProject>
- <el-button :type="items.length > 0?'primary':''" size="small" @click="delProjects" :disabled="items.length === 0">删 除</el-button>
- <tableList style="margin-top: 10px" :checkbox="true" :loading="loading" :layout="projectCols" :data="list" :opwidth="200" :custom="true" fixedName="operation" @selectionChange="selectionChange">
- <template v-slot:customcol="scope">
- <div v-if="scope.column.columnname === 'operation'">
- <span>{{scope.column.data[scope.column.columnname]}}</span>
- </div>
- <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
- </template>
- <template v-slot:opreation="scope">
- <el-button type="text" size="mini" @click="onProduct(scope.data)">添加产品</el-button>
- <el-button size="mini" type="text" @click="delProject(scope.data)">删 除</el-button>
- </template>
- </tableList>
- <tableList style="margin-top: 10px" :checkbox="true" :loading="loading" :layout="productCols" :data="productList" :opwidth="200" :custom="true" fixedName="operation">
- <template v-slot:customcol="scope">
- <div v-if="scope.column.columnname === 'operation'">
- <span>{{scope.column.data[scope.column.columnname]}}</span>
- </div>
- <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
- </template>
- <template v-slot:opreation="scope">
- <el-button size="mini" type="text" @click="delProduct(scope.data)">删 除</el-button>
- </template>
- </tableList>
- <el-drawer
- title="添加商品"
- :visible.sync="dialogVisible"
- size="90%"
- direction="rtl"
- :show-close="false"
- append-to-body
- >
- <addProduct ref="productRef" :params="paramProduct" :tablecolsAdd="tablecolsAdd" :querySa_brandid="brandid"
- :tradefield="tradefield" :discountrate="discountrate" @addProduct="addProduct" @addSuccess="addProducts"></addProduct>
- </el-drawer>
- </div>
- </template>
- <script>
- import tableList from '@/components/table/index5'
- import addProject from '@/template/prediction/addProjectTemp'
- import addProduct from '@/template/prediction/addProductTemp'
- export default {
- name: "projectList",
- components:{tableList,addProject,addProduct},
- data(){
- return {
- dialogVisible:false,
- brandid:'',
- tradefield:'',
- sa_brandid:'',
- discountrate:'',
- projectCols:[],
- productCols:[],
- tablecolsAdd:[],
- list:[],
- productList:[],
- loading:false,
- items:[],
- selectProject:'',
- projectParam:{
- "id": 20230705144904,
- "content": {
- "sa_salesforecastbillid":this.$route.query.id,
- "where":{
- "condition":""
- }
- }
- },
- productParam:{
- "id": 20230705145004,
- "content": {
- "sa_salesforecastprojectid": '',
- "where":{
- "condition":""
- }
- }
- },
- paramProject:{
- "id": 20230705145604,
- "content": {
- "pageNumber": 1,
- "pageSize": 20,
- "sa_salesforecastbillid":this.$route.query.id,
- "where": {
- "condition": ""
- }
- }
- },
- paramProduct:{
- "id": 20230705145704,
- "content": {
- "pageNumber": 1,
- "pageSize": 20,
- "sa_salesforecastbillid":this.$route.query.id,
- "sa_salesforecastprojectid":'',
- "sa_projectid":"",
- "where": {
- "condition": ""
- }
- }
- }
- }
- },
- methods:{
- /*项目列表*/
- async listData(){
- const res = await this.$api.requested(this.projectParam)
- this.list = res.data
- this.selectProject = res.data[0].sa_salesforecastprojectid
- this.productData(res.data[0].sa_salesforecastprojectid)
- },
- /*产品列表*/
- async productData(id){
- this.productParam.content.sa_salesforecastprojectid = id
- const res = await this.$api.requested(this.productParam)
- this.productList = res.data
- },
- /*添加项目*/
- async addProject(id){
- const res = await this.$api.requested({
- "id": 20230705145104,
- "content": {
- "sa_salesforecastbillid": this.$route.query.id,
- "ownertable": "sa_project",
- "salesforecastproject": [
- {
- "sa_salesforecastprojectid": 0,
- "ownerid": id,
- "discountrate": 0.1
- }
- ]
- }
- })
- this.tool.showMessage(res,()=>{
- this.projectParam.content.pageNumber = 1
- this.listData()
- })
- },
- /*批量添加项目*/
- async addProjects(ids){
- const res = await this.$api.requested({
- "id": 20230705145104,
- "content": {
- "sa_salesforecastbillid": this.$route.query.id,
- "ownertable": "sa_project",
- "salesforecastproject": ids
- }
- })
- this.tool.showMessage(res,()=>{
- this.projectParam.content.pageNumber = 1
- this.listData()
- })
- },
- /*删除项目*/
- async delProject(val){
- const res = await this.$api.requested({
- "id": 20230705145304,
- "content": {
- "sa_salesforecastbillid":this.$route.query.id,
- "sa_salesforecastprojectids":[val.sa_salesforecastprojectid]
- }
- })
- this.tool.showMessage(res,()=>{
- this.projectParam.content.pageNumber = 1
- this.listData()
- })
- },
- /*批量删除项目*/
- async delProjects(){
- console.log(this.items)
- let ids = []
- ids = this.items.map(item=>item.sa_salesforecastprojectid)
- console.log(ids)
- const res = await this.$api.requested({
- "id": 20230705145304,
- "content": {
- "sa_salesforecastbillid":this.$route.query.id,
- "sa_salesforecastprojectids":ids
- }
- })
- this.tool.showMessage(res,()=>{
- this.items = []
- this.projectParam.content.pageNumber = 1
- this.listData()
- })
- },
- /*勾选的项目*/
- selectionChange(val){
- this.items = val
- },
- /*添加产品*/
- onProduct(val){
- console.log(val,'项目信息')
- this.paramProduct.content.sa_salesforecastprojectid = val.sa_salesforecastprojectid
- this.paramProduct.content.sa_projectid = val.sa_projectid
- this.tradefield = val.tradefield
- this.sa_brandid = val.sa_brandid
- this.discountrate = val.discountrate
- this.dialogVisible = true
- this.$nextTick(()=>{
- this.$refs.productRef.onShow()
- })
- },
- async addProduct(val){
- console.log(val,'需要添加的产品')
- const res = await this.$api.requested({
- "id": 20230705145204,
- "content": {
- "sa_salesforecastbillid": this.$route.query.id,
- "sa_salesforecastprojectid": this.paramProduct.content.sa_salesforecastprojectid,
- "salesforecast": [
- {
- "itemid": val.itemid,
- "orderqty": val.qty,
- "orderamount": val.orderamount,
- "price": val.price,
- "sa_salesforecastid":0
- }
- ]
- }
- })
- this.tool.showMessage(res,()=>{
- this.dialogVisible = false
- this.productData(this.selectProject)
- })
- },
- async addProducts(val){
- console.log(val,'需要添加的产品')
- let items = []
- items = val.map(item=>{
- return {
- "itemid": item.itemid,
- "orderqty": item.qty,
- "orderamount": (item.marketprice * this.discountrate)*item.qty,
- "price": item.marketprice * this.discountrate,
- "sa_salesforecastid":0
- }
- })
- console.log(items,'item')
- const res = await this.$api.requested({
- "id": 20230705145204,
- "content": {
- "sa_salesforecastbillid": this.$route.query.id,
- "sa_salesforecastprojectid": this.paramProduct.content.sa_salesforecastprojectid,
- "salesforecast": items
- }
- })
- this.tool.showMessage(res,()=>{
- this.dialogVisible = false
- this.productData(this.selectProject)
- })
- },
- /*删除商品*/
- async delProduct(val){
- console.log(val)
- const res = await this.$api.requested({
- "id": 20230705145404,
- "content": {
- "sa_salesforecastbillid":this.$route.query.id,
- "sa_salesforecastids":[val.sa_salesforecastid]
- }
- })
- this.tool.showMessage(res,()=>{
- this.productData(this.selectProject)
- })
- }
- },
- mounted() {
- this.listData()
- },
- created() {
- this.productCols = this.tool.tabelCol(this.$route.name).productList.tablecols
- this.projectCols = this.tool.tabelCol(this.$route.name).projectList.tablecols
- this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addProductTable.tablecols
- },
- }
- </script>
- <style scoped>
- </style>
|