frockList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :export-list="exportList"
  6. :pofx="true"
  7. :operation="operation()"
  8. :column-parsing="columnParsing"
  9. :operation-column-width="160"
  10. :options-evens-group="optionsEvensGroup"
  11. :table-attributes="tableAttributes"
  12. :table-events="tableEvents"
  13. :replace-or-not-map="false"
  14. :ellipsis="false"
  15. >
  16. <Popu v-if="visible">
  17. <el-page-header slot="head" :content="content" @back="handleClose" />
  18. <FrockForm
  19. v-if="['add', 'edit','apply'].includes(module)"
  20. :detail-id="detailId"
  21. :module="module"
  22. @updateList="handleClose"
  23. />
  24. <Detail v-if="['detail'].includes(module)" :detail-id="detailId" :module="module" @updateList="handleClose" />
  25. <Examine v-if="['examine'].includes(module)" :detail-id="detailId" :module="module" @updateList="handleClose" />
  26. </Popu>
  27. <Operate v-if="operateVisible" :operate-visible="operateVisible" :operate-type="operateType" :operate-title="operateTitle" :detail-id="detailId" :record-selected="recordSelected" @close="handleClose" />
  28. </template-page>
  29. </template>
  30. <script>
  31. import TemplatePage from '@/components/template/template-page-1.vue'
  32. import import_mixin from '@/components/template/import_mixin.js'
  33. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  34. import Popu from '@/components/template/popu.vue'
  35. import FrockForm from './frockForm.vue'
  36. import Detail from './detail.vue'
  37. import Examine from './examine.vue'
  38. import Operate from '../components/operate.vue'
  39. import { getLoginFrockList, exportLoginFrock } from '@/api/frock'
  40. import { mapGetters } from 'vuex'
  41. export default {
  42. components: { TemplatePage, Popu, FrockForm, Detail, Examine, Operate },
  43. mixins: [import_mixin, add_callback_mixin],
  44. data() {
  45. return {
  46. visible: false,
  47. // 表格属性
  48. tableAttributes: {
  49. // 启用勾选列
  50. selectColumn: true
  51. }, // 关闭新增弹窗
  52. // 表格事件
  53. tableEvents: {
  54. 'selection-change': this.selectionChange
  55. },
  56. recordSelected: [],
  57. content: '新增',
  58. detailId: '',
  59. module: 'add',
  60. operateVisible: false,
  61. operateType: null,
  62. operateTitle: null
  63. }
  64. },
  65. computed: {
  66. ...mapGetters(['isTradeExaminer']),
  67. optionsEvensGroup() {
  68. return [
  69. [
  70. [
  71. {
  72. name: '添加记录',
  73. click: this.addOn(() => {
  74. this.visible = true
  75. })
  76. }
  77. ]
  78. ],
  79. ...(() => {
  80. console.log(this.isTradeExaminer, 9999)
  81. return this.isTradeExaminer
  82. ? [
  83. [
  84. [
  85. {
  86. name: '更新',
  87. click: () => {
  88. if (this.recordSelected.length === 0) {
  89. this.$message.error('请选择需要更新的数据')
  90. return
  91. }
  92. for (let index = 0; index < this.recordSelected.length; index++) {
  93. if (!(this.recordSelected[index].orderStatus == '登录成功' && this.recordSelected[index].status == '跟进中')) {
  94. this.$message.error('请选择审核通过并且跟进中的数据')
  95. return
  96. }
  97. }
  98. this.operateType = 'update'
  99. this.operateTitle = '更新'
  100. this.operateVisible = true
  101. }
  102. }
  103. ]
  104. ],
  105. [
  106. [
  107. {
  108. name: '替换业务员',
  109. click: () => {
  110. if (this.recordSelected.length === 0) {
  111. this.$message.error('请选择需要替换业务员的数据')
  112. return
  113. }
  114. for (let index = 0; index < this.recordSelected.length; index++) {
  115. if (this.recordSelected[index].orderStatus !== '登录成功') {
  116. this.$message.error('请选择审核通过的数据')
  117. return
  118. }
  119. }
  120. this.operateType = 'replace'
  121. this.operateTitle = '替换业务员'
  122. this.operateVisible = true
  123. }
  124. }
  125. ]
  126. ],
  127. [
  128. [
  129. {
  130. name: '删除',
  131. click: () => {
  132. if (this.recordSelected.length === 0) {
  133. this.$message.error('请选择需要删除的数据')
  134. return
  135. }
  136. for (let index = 0; index < this.recordSelected.length; index++) {
  137. if (this.recordSelected[index].orderStatus !== '登录成功') {
  138. this.$message.error('请选择审核通过的数据')
  139. return
  140. }
  141. }
  142. this.operateType = 'delete'
  143. this.operateTitle = '删除'
  144. this.operateVisible = true
  145. }
  146. }
  147. ]
  148. ]
  149. ]
  150. : []
  151. })()
  152. ]
  153. }
  154. },
  155. created() {
  156. this.getCurrentRoute()
  157. },
  158. methods: {
  159. // 列表请求函数
  160. getList(...p) {
  161. this.recordSelected = []
  162. return getLoginFrockList(...p)
  163. },
  164. // 列表导出函数
  165. exportList: exportLoginFrock,
  166. // 表格列解析渲染数据更改
  167. columnParsing(item, defaultData) {
  168. if (item.colName === 'project_no') {
  169. defaultData.render = (h, { row, index, column }) => {
  170. return (<el-link type='primary' underline={false} onClick={() => {
  171. const page = this.$router.resolve({
  172. path: '/commercialEngineering/frockList',
  173. query: {
  174. detailId: row.id,
  175. module: 'detail'
  176. }
  177. })
  178. window.open(page.href, '_blank')
  179. }}>{row.projectNo}</el-link>)
  180. }
  181. }
  182. return defaultData
  183. },
  184. // 监听勾选变化
  185. selectionChange(data) {
  186. this.recordSelected = data
  187. console.log(data)
  188. },
  189. operation() {
  190. return (h, { row, index, column }) => {
  191. return (
  192. <div class='operation-btns'>
  193. {this.isTradeExaminer && (row.orderStatus === 'WAIT' || row.orderStatus === 'OK' || row.orderStatus === 'FAIL') ? (
  194. <el-button
  195. size='mini'
  196. type='text'
  197. onClick={() => {
  198. this.content = '审核'
  199. this.module = 'examine'
  200. this.detailId = row.id
  201. this.visible = true
  202. }}
  203. >
  204. 审核
  205. </el-button>
  206. ) : null}
  207. {/* {
  208. <el-button
  209. size='mini'
  210. type='text'
  211. onClick={() => {
  212. this.content = '详情'
  213. this.module = 'detail'
  214. this.detailId = row.id
  215. this.visible = true
  216. }}
  217. >
  218. 详情
  219. </el-button>
  220. } */}
  221. {(row.orderStatus === 'SAVE' || row.orderStatus === 'RETURN')
  222. ? <el-button
  223. size='mini'
  224. type='text'
  225. onClick={() => {
  226. this.content = '编辑'
  227. this.module = 'edit'
  228. this.detailId = row.id
  229. this.visible = true
  230. }}
  231. >
  232. 编辑
  233. </el-button> : null
  234. }
  235. {row.orderStatus === 'OK' && row.status === 'ING'
  236. ? <el-button size='mini' type='text' onClick={() => {
  237. this.operateType = 'update'
  238. this.operateTitle = '更新'
  239. this.recordSelected = [row]
  240. this.operateVisible = true
  241. }}>
  242. 更新
  243. </el-button> : null
  244. }
  245. {!this.isTradeExaminer && ((row.orderStatus === 'OK') && row.status === 'ING' && !row.isApplyUpdate) ? (
  246. <el-button
  247. size='mini'
  248. type='text'
  249. onClick={() => {
  250. this.detailId = row.id
  251. this.operateType = 'apply'
  252. this.operateTitle = '申请修改'
  253. this.operateVisible = true
  254. }}
  255. >
  256. 申请修改
  257. </el-button>
  258. ) : null}
  259. {this.isTradeExaminer && ((row.orderStatus === 'OK' || row.orderStatus === 'FAIL') && row.isApplyUpdate) ? (
  260. <el-button
  261. size='mini'
  262. type='text'
  263. onClick={() => {
  264. this.detailId = row.id
  265. this.operateType = 'examine'
  266. this.operateTitle = '审核修改'
  267. this.operateVisible = true
  268. }}
  269. >
  270. 审核修改
  271. </el-button>
  272. ) : null}
  273. </div>
  274. )
  275. }
  276. },
  277. handleClose() {
  278. this.getCurrentRoute('OK')
  279. this.addOff(() => {
  280. this.content = '新增'
  281. this.module = 'add'
  282. this.detailId = ''
  283. this.operateVisible = false
  284. this.operateTitle = null
  285. this.operateType = null
  286. this.visible = false
  287. this.$refs.pageRef.refreshList()
  288. })()
  289. },
  290. getCurrentRoute(back) {
  291. const { detailId, module } = this.$route.query
  292. if (back === 'OK' && module === 'detail') {
  293. this.$router.replace('/commercialEngineering/frockList')
  294. return
  295. }
  296. if (detailId && module === 'detail') {
  297. this.content = '详情'
  298. this.detailId = detailId
  299. this.module = module
  300. this.visible = true
  301. }
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped></style>