index copy.vue 9.3 KB

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