index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="sales">
  3. <div class="container normal-panel">
  4. <p class="normal-title normal-margin">预测提报任务</p>
  5. <div class="header-handle">
  6. <Search @searchActive="searchActive" @clearData="clearData" />
  7. <DownSelect @selectChange="categoryChange" @clearCategory="clearCategory" title="提报要求:"
  8. :list="[{label:'按产品类别预测',value:'0'},{label:'按项目及产品类别预测',value:'1'}]" style="margin-right:16px" />
  9. </div>
  10. <tableLayout v-if="salesPanelList" :layout="tablecols" :data="salesPanelList" :custom="true" height="30vh"
  11. @rowClick="rowClick">
  12. <template v-slot:customcol="scope">
  13. <div v-if="scope.column.columnname == 'periodtype'">
  14. <span>
  15. {{scope.column.data.periodpoint | timer(scope.column.data[scope.column.columnname])}}
  16. </span>
  17. </div>
  18. <div v-else-if="scope.column.columnname == 'baseonproject'">
  19. <span v-if="scope.column.data[scope.column.columnname] == '1'">按项目及产品类别预测</span>
  20. <span v-else>按产品类别预测</span>
  21. </div>
  22. <div v-else-if="scope.column.columnname == 'date'">
  23. <span>{{scope.column.data.begdate}}至{{scope.column.data.enddate}}</span>
  24. </div>
  25. <span v-else>{{scope.column.data[scope.column.columnname]}}</span>
  26. </template>
  27. <template v-slot:opreation="scope">
  28. <el-button type="text" size="small" @click="addBuill(scope)"
  29. v-if="tool.checkAuth($route.name,'create_sales')">创建提报</el-button>
  30. </template>
  31. </tableLayout>
  32. <pagination :total="total" :pageSize="params.content.pageSize" :currentPage="params.content.pageNumber"
  33. @pageChange="pageChange" style="margin-top:16px;display:flex;justify-content: flex-end;">
  34. </pagination>
  35. </div>
  36. <div class="container normal-panel" style="margin-top:16px">
  37. <p class="normal-title normal-margin">销售预测记录</p>
  38. <div class="header-handle">
  39. <Search @searchActive="searchActive2" @clearData="clearData2" />
  40. <time-select @clearSelect="clearTime" @timeChange="timeChange" title="提报时间:"></time-select>
  41. </div>
  42. <tableLayout :layout="tablecols2" :data="historyList" :custom="true" height="30vh">
  43. <template v-slot:customcol="scope">
  44. <div v-if="scope.column.columnname == 'periodtype'">
  45. <span>
  46. {{scope.column.data.periodpoint | timer(scope.column.data[scope.column.columnname])}}
  47. </span>
  48. </div>
  49. <div v-else-if="scope.column.columnname == 'baseonproject'">
  50. <span v-if="scope.column.data[scope.column.columnname] == '1'">按项目及产品类别预测</span>
  51. <span v-else>按产品类别预测</span>
  52. </div>
  53. <span v-else>{{scope.column.data[scope.column.columnname]}}</span>
  54. </template>
  55. <template v-slot:opreation="scope">
  56. <el-button type="text" size="small" @click="goDetail(scope.data)"
  57. v-if="tool.checkAuth($route.name,'read') && scope.data.isoverdue == 1">详情</el-button>
  58. <el-button type="text" size="small" @click="goEdit(scope.data)"
  59. v-else-if="tool.checkAuth($route.name,'update') && scope.data.isoverdue == 0">编辑</el-button>
  60. </template>
  61. </tableLayout>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import Header from '@/SManagement/archives_upload/components/Header'
  67. import Search from '@/components/search/index'
  68. import DownSelect from '@/components/down_select/index'
  69. import TimeSelect from '@/SManagement/submitedit_one/components/TimeSelect'
  70. import Pagination from '@/components/pagination/Pagination'
  71. import { log } from '@antv/g2plot/lib/utils'
  72. export default {
  73. name: '',
  74. data () {
  75. return {
  76. params: {
  77. "id": 20220906154403,
  78. "version": 1,
  79. "content": {
  80. "nocache": true,
  81. "pageNumber": 1,
  82. "pageSize": 12,
  83. "where": {
  84. "condition": "",
  85. "baseonproject": "",
  86. "begindate": '',
  87. "enddate": ''
  88. }
  89. }
  90. },
  91. /* 销售模板list */
  92. salesPanelList: '',
  93. /* 当前选中的模板id */
  94. selectPanelId: '',
  95. /* 提报记录数据 */
  96. historyList: [],
  97. tablecols: '',
  98. tablecols2: '',
  99. total: 0,
  100. /* 开始时间 */
  101. begindate: '',
  102. /* 结束时间 */
  103. enddate: '',
  104. condition:''
  105. };
  106. },
  107. components: { Header, Search, DownSelect, TimeSelect, Pagination },
  108. computed: {
  109. },
  110. watch: {
  111. },
  112. filters: {
  113. timer (val, type) {
  114. if (type == '月') {
  115. return '每月' + val.substr(1, val.length - 2) + '日'
  116. } else {
  117. return '每周' + val.substr(1, val.length - 2)
  118. }
  119. }
  120. },
  121. created () {
  122. this.getSalesPanel()
  123. this.tablecols = this.tool.tabelCol(this.$route.name).SalesPanelTable.tablecols
  124. this.tablecols2 = this.tool.tabelCol(this.$route.name).salesHistoryTable.tablecols
  125. },
  126. methods: {
  127. /* 获取销售预测模板 */
  128. async getSalesPanel () {
  129. let res = await this.$api.requested(this.params)
  130. this.salesPanelList = res.data
  131. this.total = res.total
  132. this.historyList = []
  133. console.log(res);
  134. },
  135. /* 获取提报记录数据 */
  136. async getSalesDetail () {
  137. let res = await this.$api.requested({
  138. "id": 20220908134403,
  139. "version": 1,
  140. "content": {
  141. "nocache": true,
  142. "sa_salesforecastmodelid": this.selectPanelId,
  143. "where": {
  144. "begindate": this.begindate,
  145. "enddate": this.enddate,
  146. "condition":this.condition
  147. }
  148. }
  149. })
  150. this.historyList = res.data
  151. console.log(this.historyList);
  152. },
  153. async rowClick (data) {
  154. this.selectPanelId = data.sa_salesforecastmodelid
  155. this.getSalesDetail()
  156. },
  157. /* 创建提报 */
  158. async addBuill (data) {
  159. let res = await this.$api.requested({
  160. "id": 20220913154403,
  161. "version": 1,
  162. "content": {
  163. "sa_salesforecastmodelid": data.data.sa_salesforecastmodelid,
  164. "sa_salesforecastbillid": 0,
  165. "sa_projectids": data.data.baseonproject == 1 ? [] : [0]
  166. }
  167. })
  168. if (res.code == 0) {
  169. this.$notify({
  170. title: '提示',
  171. message: res.msg,
  172. type: 'warning'
  173. })
  174. } else {
  175. console.log(res);
  176. this.$router.push({ path: data.data.baseonproject == 1 ? '/edit_sales' : '/edit_product', query: { id: res.data[0].sa_salesforecastbillid, id2: data.data.sa_salesforecastmodelid, header: 'panel' } })
  177. }
  178. },
  179. /* 前往详情页 */
  180. goDetail (data) {
  181. if (data.baseonproject == 0) {
  182. this.$router.push({ path: '/product_detail', query: { id: data.sa_salesforecastbillid } })
  183. } else {
  184. this.$router.push({ path: '/project_detail', query: { id: data.sa_salesforecastbillid, type: 'product' } })
  185. }
  186. },
  187. /* 前往编辑页 */
  188. goEdit (data) {
  189. /* 跳转到产品编辑页 */
  190. if (data.baseonproject == 0) {
  191. this.$router.push({ path: '/edit_product', query: { id: data.sa_salesforecastbillid, id2: data.sa_salesforecastmodelid } })
  192. /* 跳转到项目编辑页 */
  193. } else {
  194. this.$router.push({ path: '/edit_sales', query: { id: data.sa_salesforecastbillid, id2: data.sa_salesforecastmodelid, type: 'project' } })
  195. }
  196. },
  197. pageChange (n) {
  198. this.params.content.pageNumber = n
  199. this.getSalesPanel()
  200. },
  201. /* 模板搜索 */
  202. searchActive (data) {
  203. this.params.content.where.condition = data
  204. this.params.content.pageNumber = 1
  205. this.getSalesPanel()
  206. },
  207. /* 模板清除搜索 */
  208. clearData () {
  209. this.params.content.where.condition = ''
  210. this.params.content.pageNumber = 1
  211. this.getSalesPanel()
  212. },
  213. /* 提报搜索 */
  214. searchActive2 (data) {
  215. this.condition = data
  216. this.params.content.pageNumber = 1
  217. this.getSalesDetail()
  218. },
  219. /* 提报清除搜索 */
  220. clearData2 () {
  221. this.condition = ''
  222. this.params.content.pageNumber = 1
  223. this.getSalesDetail()
  224. },
  225. /* 清除分类 */
  226. clearCategory () {
  227. this.params.content.where.baseonproject = ''
  228. this.params.content.pageNumber = 1
  229. this.getSalesPanel()
  230. },
  231. /* 分类改变 */
  232. categoryChange (data) {
  233. console.log(222);
  234. this.params.content.where.baseonproject = data
  235. this.params.content.pageNumber = 1
  236. this.getSalesPanel()
  237. },
  238. /* 时间赛选改变 */
  239. timeChange (time) {
  240. this.begindate = time[0]
  241. this.enddate = time[1]
  242. this.getSalesDetail()
  243. },
  244. /* 清除时间赛选 */
  245. clearTime () {
  246. this.begindate = ''
  247. this.enddate = ''
  248. this.getSalesDetail()
  249. },
  250. },
  251. };
  252. </script>
  253. <style scoped>
  254. .sales .header-handle {
  255. display: flex;
  256. align-items: center;
  257. margin-bottom: 16px;
  258. }
  259. </style>