projectList.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div>
  3. <addProject ref="addProject" :param="paramProject" class="inline-16" @add="addProject" @adds="addProjects"></addProject>
  4. <el-button :type="items.length > 0?'primary':''" size="small" @click="delProjects" :disabled="items.length === 0">删 除</el-button>
  5. <tableList style="margin-top: 10px" :checkbox="true" :loading="loading" :layout="projectCols" :data="list" :opwidth="200" :custom="true" fixedName="operation" @selectionChange="selectionChange">
  6. <template v-slot:customcol="scope">
  7. <div v-if="scope.column.columnname === 'operation'">
  8. <span>{{scope.column.data[scope.column.columnname]}}</span>
  9. </div>
  10. <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
  11. </template>
  12. <template v-slot:opreation="scope">
  13. <el-button type="text" size="mini" @click="onProduct(scope.data)">添加产品</el-button>
  14. <el-button size="mini" type="text" @click="delProject(scope.data)">删 除</el-button>
  15. </template>
  16. </tableList>
  17. <tableList style="margin-top: 10px" :checkbox="true" :loading="loading" :layout="productCols" :data="productList" :opwidth="200" :custom="true" fixedName="operation">
  18. <template v-slot:customcol="scope">
  19. <div v-if="scope.column.columnname === 'operation'">
  20. <span>{{scope.column.data[scope.column.columnname]}}</span>
  21. </div>
  22. <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
  23. </template>
  24. <template v-slot:opreation="scope">
  25. <el-button size="mini" type="text" @click="delProduct(scope.data)">删 除</el-button>
  26. </template>
  27. </tableList>
  28. <el-drawer
  29. title="添加商品"
  30. :visible.sync="dialogVisible"
  31. size="90%"
  32. direction="rtl"
  33. :show-close="false"
  34. append-to-body
  35. >
  36. <addProduct ref="productRef" :params="paramProduct" :tablecolsAdd="tablecolsAdd" :querySa_brandid="brandid"
  37. :tradefield="tradefield" :discountrate="discountrate" @addProduct="addProduct" @addSuccess="addProducts"></addProduct>
  38. </el-drawer>
  39. </div>
  40. </template>
  41. <script>
  42. import tableList from '@/components/table/index5'
  43. import addProject from '@/template/prediction/addProjectTemp'
  44. import addProduct from '@/template/prediction/addProductTemp'
  45. export default {
  46. name: "projectList",
  47. components:{tableList,addProject,addProduct},
  48. data(){
  49. return {
  50. dialogVisible:false,
  51. brandid:'',
  52. tradefield:'',
  53. sa_brandid:'',
  54. discountrate:'',
  55. projectCols:[],
  56. productCols:[],
  57. tablecolsAdd:[],
  58. list:[],
  59. productList:[],
  60. loading:false,
  61. items:[],
  62. selectProject:'',
  63. projectParam:{
  64. "id": 20230705144904,
  65. "content": {
  66. "sa_salesforecastbillid":this.$route.query.id,
  67. "where":{
  68. "condition":""
  69. }
  70. }
  71. },
  72. productParam:{
  73. "id": 20230705145004,
  74. "content": {
  75. "sa_salesforecastprojectid": '',
  76. "where":{
  77. "condition":""
  78. }
  79. }
  80. },
  81. paramProject:{
  82. "id": 20230705145604,
  83. "content": {
  84. "pageNumber": 1,
  85. "pageSize": 20,
  86. "sa_salesforecastbillid":this.$route.query.id,
  87. "where": {
  88. "condition": ""
  89. }
  90. }
  91. },
  92. paramProduct:{
  93. "id": 20230705145704,
  94. "content": {
  95. "pageNumber": 1,
  96. "pageSize": 20,
  97. "sa_salesforecastbillid":this.$route.query.id,
  98. "sa_salesforecastprojectid":'',
  99. "sa_projectid":"",
  100. "where": {
  101. "condition": ""
  102. }
  103. }
  104. }
  105. }
  106. },
  107. methods:{
  108. /*项目列表*/
  109. async listData(){
  110. const res = await this.$api.requested(this.projectParam)
  111. this.list = res.data
  112. this.selectProject = res.data[0].sa_salesforecastprojectid
  113. this.productData(res.data[0].sa_salesforecastprojectid)
  114. },
  115. /*产品列表*/
  116. async productData(id){
  117. this.productParam.content.sa_salesforecastprojectid = id
  118. const res = await this.$api.requested(this.productParam)
  119. this.productList = res.data
  120. },
  121. /*添加项目*/
  122. async addProject(id){
  123. const res = await this.$api.requested({
  124. "id": 20230705145104,
  125. "content": {
  126. "sa_salesforecastbillid": this.$route.query.id,
  127. "ownertable": "sa_project",
  128. "salesforecastproject": [
  129. {
  130. "sa_salesforecastprojectid": 0,
  131. "ownerid": id,
  132. "discountrate": 0.1
  133. }
  134. ]
  135. }
  136. })
  137. this.tool.showMessage(res,()=>{
  138. this.projectParam.content.pageNumber = 1
  139. this.listData()
  140. })
  141. },
  142. /*批量添加项目*/
  143. async addProjects(ids){
  144. const res = await this.$api.requested({
  145. "id": 20230705145104,
  146. "content": {
  147. "sa_salesforecastbillid": this.$route.query.id,
  148. "ownertable": "sa_project",
  149. "salesforecastproject": ids
  150. }
  151. })
  152. this.tool.showMessage(res,()=>{
  153. this.projectParam.content.pageNumber = 1
  154. this.listData()
  155. })
  156. },
  157. /*删除项目*/
  158. async delProject(val){
  159. const res = await this.$api.requested({
  160. "id": 20230705145304,
  161. "content": {
  162. "sa_salesforecastbillid":this.$route.query.id,
  163. "sa_salesforecastprojectids":[val.sa_salesforecastprojectid]
  164. }
  165. })
  166. this.tool.showMessage(res,()=>{
  167. this.projectParam.content.pageNumber = 1
  168. this.listData()
  169. })
  170. },
  171. /*批量删除项目*/
  172. async delProjects(){
  173. console.log(this.items)
  174. let ids = []
  175. ids = this.items.map(item=>item.sa_salesforecastprojectid)
  176. console.log(ids)
  177. const res = await this.$api.requested({
  178. "id": 20230705145304,
  179. "content": {
  180. "sa_salesforecastbillid":this.$route.query.id,
  181. "sa_salesforecastprojectids":ids
  182. }
  183. })
  184. this.tool.showMessage(res,()=>{
  185. this.items = []
  186. this.projectParam.content.pageNumber = 1
  187. this.listData()
  188. })
  189. },
  190. /*勾选的项目*/
  191. selectionChange(val){
  192. this.items = val
  193. },
  194. /*添加产品*/
  195. onProduct(val){
  196. console.log(val,'项目信息')
  197. this.paramProduct.content.sa_salesforecastprojectid = val.sa_salesforecastprojectid
  198. this.paramProduct.content.sa_projectid = val.sa_projectid
  199. this.tradefield = val.tradefield
  200. this.sa_brandid = val.sa_brandid
  201. this.discountrate = val.discountrate
  202. this.dialogVisible = true
  203. this.$nextTick(()=>{
  204. this.$refs.productRef.onShow()
  205. })
  206. },
  207. async addProduct(val){
  208. console.log(val,'需要添加的产品')
  209. const res = await this.$api.requested({
  210. "id": 20230705145204,
  211. "content": {
  212. "sa_salesforecastbillid": this.$route.query.id,
  213. "sa_salesforecastprojectid": this.paramProduct.content.sa_salesforecastprojectid,
  214. "salesforecast": [
  215. {
  216. "itemid": val.itemid,
  217. "orderqty": val.qty,
  218. "orderamount": val.orderamount,
  219. "price": val.price,
  220. "sa_salesforecastid":0
  221. }
  222. ]
  223. }
  224. })
  225. this.tool.showMessage(res,()=>{
  226. this.dialogVisible = false
  227. this.productData(this.selectProject)
  228. })
  229. },
  230. async addProducts(val){
  231. console.log(val,'需要添加的产品')
  232. let items = []
  233. items = val.map(item=>{
  234. return {
  235. "itemid": item.itemid,
  236. "orderqty": item.qty,
  237. "orderamount": (item.marketprice * this.discountrate)*item.qty,
  238. "price": item.marketprice * this.discountrate,
  239. "sa_salesforecastid":0
  240. }
  241. })
  242. console.log(items,'item')
  243. const res = await this.$api.requested({
  244. "id": 20230705145204,
  245. "content": {
  246. "sa_salesforecastbillid": this.$route.query.id,
  247. "sa_salesforecastprojectid": this.paramProduct.content.sa_salesforecastprojectid,
  248. "salesforecast": items
  249. }
  250. })
  251. this.tool.showMessage(res,()=>{
  252. this.dialogVisible = false
  253. this.productData(this.selectProject)
  254. })
  255. },
  256. /*删除商品*/
  257. async delProduct(val){
  258. console.log(val)
  259. const res = await this.$api.requested({
  260. "id": 20230705145404,
  261. "content": {
  262. "sa_salesforecastbillid":this.$route.query.id,
  263. "sa_salesforecastids":[val.sa_salesforecastid]
  264. }
  265. })
  266. this.tool.showMessage(res,()=>{
  267. this.productData(this.selectProject)
  268. })
  269. }
  270. },
  271. mounted() {
  272. this.listData()
  273. },
  274. created() {
  275. this.productCols = this.tool.tabelCol(this.$route.name).productList.tablecols
  276. this.projectCols = this.tool.tabelCol(this.$route.name).projectList.tablecols
  277. this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addProductTable.tablecols
  278. },
  279. }
  280. </script>
  281. <style scoped>
  282. </style>