frockList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. [
  131. [
  132. {
  133. name: '删除',
  134. click: () => {
  135. if (this.recordSelected.length === 0) {
  136. this.$message.error('请选择需要删除的数据')
  137. return
  138. }
  139. if(!this.isTradeExaminer){
  140. for (let index = 0; index < this.recordSelected.length; index++) {
  141. if (this.recordSelected[index].orderStatus !== '保存') {
  142. this.$message.error('请选择保存的数据')
  143. return
  144. }
  145. }
  146. }
  147. // for (let index = 0; index < this.recordSelected.length; index++) {
  148. // if (this.recordSelected[index].orderStatus !== '已审核') {
  149. // this.$message.error('请选择审核通过的数据')
  150. // return
  151. // }
  152. // }
  153. this.operateType = 'delete'
  154. this.operateTitle = '删除'
  155. this.operateVisible = true
  156. }
  157. }
  158. ]
  159. ]
  160. ]
  161. }
  162. },
  163. created() {
  164. this.getCurrentRoute()
  165. },
  166. methods: {
  167. // 列表请求函数
  168. getList(...p) {
  169. this.recordSelected = []
  170. return getLoginFrockList(...p)
  171. },
  172. // 列表导出函数
  173. exportList: exportLoginFrock,
  174. // 表格列解析渲染数据更改
  175. columnParsing(item, defaultData) {
  176. if (item.colName === 'project_no') {
  177. defaultData.render = (h, { row, index, column }) => {
  178. return (<el-link type='primary' underline={false} onClick={() => {
  179. const page = this.$router.resolve({
  180. path: '/commercialEngineering/frockList',
  181. query: {
  182. detailId: row.id,
  183. module: 'detail'
  184. }
  185. })
  186. window.open(page.href, '_blank')
  187. }}>{row.projectNo}</el-link>)
  188. }
  189. }
  190. return defaultData
  191. },
  192. // 监听勾选变化
  193. selectionChange(data) {
  194. this.recordSelected = data
  195. console.log(data)
  196. },
  197. operation() {
  198. return (h, { row, index, column }) => {
  199. return (
  200. <div class='operation-btns'>
  201. {!this.isTradeExaminer && ((row.orderStatus === 'OK') && row.status === 'ING' && !row.isApplyUpdate) ? (
  202. <el-button
  203. size='mini'
  204. type='text'
  205. onClick={() => {
  206. this.detailId = row.id
  207. this.operateType = 'apply'
  208. this.operateTitle = '申请修改'
  209. this.operateVisible = true
  210. }}
  211. >
  212. 申请修改
  213. </el-button>
  214. ) : null}
  215. {this.isTradeExaminer && row.orderStatus !== 'SAVE' ? (
  216. <el-button
  217. size='mini'
  218. type='text'
  219. onClick={() => {
  220. this.content = '审核'
  221. this.module = 'examine'
  222. this.detailId = row.id
  223. this.visible = true
  224. }}
  225. >
  226. 审核
  227. </el-button>
  228. ) : null}
  229. {/* {
  230. <el-button
  231. size='mini'
  232. type='text'
  233. onClick={() => {
  234. this.content = '详情'
  235. this.module = 'detail'
  236. this.detailId = row.id
  237. this.visible = true
  238. }}
  239. >
  240. 详情
  241. </el-button>
  242. } */}
  243. {(this.isTradeExaminer &&
  244. (row.orderStatus === 'SAVE' || row.orderStatus === 'RETURN') && row.status === 'ING') ||
  245. row.orderStatus === 'SAVE' ||
  246. row.orderStatus === 'RETURN'
  247. ? <el-button
  248. size='mini'
  249. type='text'
  250. onClick={() => {
  251. this.content = '编辑'
  252. this.module = 'edit'
  253. this.detailId = row.id
  254. this.visible = true
  255. }}
  256. >
  257. 编辑
  258. </el-button> : null
  259. }
  260. {row.orderStatus === 'OK' && row.status === 'ING'
  261. ? <el-button size='mini' type='text' onClick={() => {
  262. this.operateType = 'update'
  263. this.operateTitle = '更新'
  264. this.recordSelected = [row]
  265. this.operateVisible = true
  266. }}>
  267. 更新
  268. </el-button> : null
  269. }
  270. {this.isTradeExaminer && ((row.orderStatus === 'OK' || row.orderStatus === 'FAIL') && row.isApplyUpdate) ? (
  271. <el-button
  272. size='mini'
  273. type='text'
  274. onClick={() => {
  275. this.detailId = row.id
  276. this.operateType = 'examine'
  277. this.operateTitle = '审核修改'
  278. this.operateVisible = true
  279. }}
  280. >
  281. 审核修改
  282. </el-button>
  283. ) : null}
  284. </div>
  285. )
  286. }
  287. },
  288. handleClose() {
  289. this.getCurrentRoute('OK')
  290. this.addOff(() => {
  291. this.content = '新增'
  292. this.module = 'add'
  293. this.detailId = ''
  294. this.operateVisible = false
  295. this.operateTitle = null
  296. this.operateType = null
  297. this.visible = false
  298. this.$refs.pageRef.refreshList()
  299. })()
  300. },
  301. getCurrentRoute(back) {
  302. const { detailId, module } = this.$route.query
  303. if (back === 'OK' && module === 'detail') {
  304. this.$router.replace('/commercialEngineering/frockList')
  305. return
  306. }
  307. if (detailId && module === 'detail') {
  308. this.content = '详情'
  309. this.detailId = detailId
  310. this.module = module
  311. this.visible = true
  312. }
  313. }
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped></style>