index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :table-attributes="tableAttributes"
  6. :table-events="tableEvents"
  7. :operationColumnWidth="80"
  8. :options-evens-group="optionsEvensGroup"
  9. :moreParameters="moreParameters"
  10. :column-parsing="columnParsing"
  11. :operation="operation()"
  12. :exportList="exportList"
  13. >
  14. <div slot="moreSearch">
  15. <el-radio-group v-model="poolStatus" size="mini" @change="changeType">
  16. <el-radio-button label="">全部</el-radio-button>
  17. <el-radio-button label="NO">未汇总</el-radio-button>
  18. <el-radio-button label="YES">已汇总</el-radio-button>
  19. </el-radio-group>
  20. <br /><br />
  21. </div>
  22. <el-dialog
  23. title=""
  24. width="600px"
  25. custom-class="diy-dialog"
  26. append-to-body
  27. :modal="true"
  28. :visible.sync="formDialog"
  29. :show-close="true"
  30. :close-on-click-modal="false"
  31. :modal-append-to-body="false"
  32. :before-close="formCancel"
  33. >
  34. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  35. <zj-form-module
  36. :title="formDialogTitles[formDialogType]"
  37. label-width="120px"
  38. :showPackUp="false"
  39. :form-data="formData"
  40. :form-items="formItems"
  41. :disabled="formDialogType == 2"
  42. >
  43. </zj-form-module>
  44. </zj-form-container>
  45. <div slot="footer" class="dialog-footer">
  46. <el-button size="mini" @click="formCancel">取 消</el-button>
  47. <el-button size="mini" v-if="formDialogType !== 2" type="primary" @click="formConfirm()">提交</el-button>
  48. </div>
  49. </el-dialog>
  50. </template-page>
  51. </template>
  52. <script>
  53. import TemplatePage from '@/components/template/template-page-1.vue'
  54. import import_mixin from '@/components/template/import_mixin.js'
  55. import ImageUpload from '@/components/file-upload'
  56. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  57. import { listPageV2, pageExport, pool, poolMore } from '@/api/workOrder/settleAccountsOrder'
  58. import operation_mixin from '@/components/template/operation_mixin.js'
  59. export default {
  60. components: { TemplatePage, ImageUpload },
  61. mixins: [import_mixin, operation_mixin],
  62. data() {
  63. return {
  64. // 表格属性
  65. tableAttributes: {
  66. // 启用勾选列
  67. selectColumn: true,
  68. selectable: this.selectable
  69. },
  70. // 表格事件
  71. tableEvents: {
  72. 'selection-change': this.selectionChange
  73. },
  74. // 勾选选中行
  75. recordSelected: [],
  76. /** 表单变量 */
  77. formDialogType: 0,
  78. formDialogTitles: ['汇总'],
  79. formDialog: false,
  80. type: JSON.parse(localStorage.getItem('greemall_user')).type, //type=1商户, type=0网点
  81. formData: {
  82. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  83. month:
  84. new Date().getFullYear() +
  85. '-' +
  86. (new Date().getMonth() + 1 > 9 ? new Date().getMonth() + 1 : '0' + (new Date().getMonth() + 1)),
  87. createdTime: [],
  88. starDate: '',
  89. endDate: ''
  90. },
  91. poolStatus: ''
  92. }
  93. },
  94. computed: {
  95. // 事件组合
  96. optionsEvensGroup() {
  97. return [
  98. [
  99. [
  100. this.optionsEvensAuth('collectMonth', {
  101. click: this.poolData1
  102. })
  103. ]
  104. ],
  105. [
  106. [
  107. this.optionsEvensAuth('collectMore', {
  108. click: this.poolData2
  109. })
  110. ]
  111. ]
  112. ]
  113. },
  114. // 更多参数
  115. moreParameters() {
  116. return []
  117. },
  118. formItems() {
  119. return [
  120. {
  121. md: 24,
  122. isShow: true,
  123. name: 'el-input',
  124. attributes: { placeholder: '请输入', disabled: true },
  125. formItemAttributes: {
  126. label: '月份',
  127. prop: 'month',
  128. rules: [...required]
  129. }
  130. },
  131. {
  132. md: 24,
  133. isShow: true,
  134. name: 'slot-component',
  135. attributes: { placeholder: '请选择' },
  136. formItemAttributes: {
  137. label: '创建结算单时间',
  138. prop: 'createdTime',
  139. rules: [...required]
  140. },
  141. render: (h, { props, onInput }) => {
  142. var { value } = props
  143. return (
  144. <el-date-picker
  145. v-model={this.formData.createdTime}
  146. type="daterange"
  147. range-separator="至"
  148. value-format="yyyy-MM-dd"
  149. start-placeholder="开始日期"
  150. end-placeholder="结束日期"
  151. onChange={e => {
  152. this.formData.starDate = e[0]
  153. this.formData.endDate = e[1]
  154. }}
  155. ></el-date-picker>
  156. )
  157. }
  158. }
  159. ]
  160. }
  161. },
  162. methods: {
  163. // 切换状态
  164. changeType(val) {
  165. this.$refs.pageRef.refreshList()
  166. },
  167. // 列表请求函数
  168. getList(p, cb) {
  169. try {
  170. var pam = JSON.parse(JSON.stringify(p))
  171. pam.params.push({ param: 'a.pool_status', compare: '=', value: this.poolStatus })
  172. cb && cb(pam)
  173. return listPageV2(pam)
  174. } catch (error) {
  175. console.log(error)
  176. }
  177. },
  178. // 列表导出函数
  179. exportList: pageExport,
  180. // 表格列解析渲染数据更改
  181. columnParsing(item, defaultData) {
  182. if (item.jname === 'orderBaseId') {
  183. defaultData.render = (h, { row, index, column }) => {
  184. return (
  185. <div style="padding:0 6px;cursor: pointer;" class={{ 'text-view': true, 'text-view-copy': column.isCopy }}>
  186. <span
  187. style="color:#008dd4;"
  188. onClick={() => {
  189. if (row.settleOrderType == 'EXAMINE') {
  190. this.$router.push({
  191. name: 'rewardsPunishmentsOrder',
  192. query: {
  193. id: row.examineProjectId
  194. }
  195. })
  196. } else if (row.settleOrderType == 'PUNISH') {
  197. this.$router.push({
  198. name: 'penaltyWorkOrder',
  199. params: {
  200. pageName: row.punishOrderId,
  201. pageType: 'detail',
  202. pageCode: row.punishOrderId
  203. }
  204. })
  205. } else {
  206. this.$router.push({
  207. name: 'workOrderPool',
  208. params: {
  209. pageName: row.orderBaseId,
  210. pageType: 'detail',
  211. pageCode: row.orderBaseId,
  212. pagePam: 'SettleAccounts'
  213. }
  214. })
  215. }
  216. }}
  217. >
  218. {row.orderBaseId}
  219. </span>
  220. {column.isCopy && row.orderBaseId ? (
  221. <i
  222. style="color:#008dd4;"
  223. class={['el-icon-document-copy', column.columnCopyClass]}
  224. data-clipboard-text={row[column.columnAttributes.prop]}
  225. ></i>
  226. ) : null}
  227. </div>
  228. )
  229. }
  230. defaultData.columnAttributes.width = 200
  231. }
  232. return defaultData
  233. },
  234. selectable(row, index) {
  235. return ['NO'].includes(
  236. Object.entries(row.selectMapData.poolStatus).find(([key, val]) => val == row.poolStatus)?.[0]
  237. )
  238. },
  239. // 监听勾选变化
  240. selectionChange(data) {
  241. this.recordSelected = data
  242. },
  243. operation() {
  244. return this.operationBtn({
  245. detail: {
  246. click: ({ row, index, column }) => {
  247. if (row.settleOrderType == 'EXAMINE') {
  248. this.$router.push({
  249. name: 'rewardsPunishmentsOrder',
  250. query: {
  251. id: row.examineProjectId
  252. }
  253. })
  254. } else if (row.settleOrderType == 'PUNISH') {
  255. this.$router.push({
  256. name: 'penaltyWorkOrder',
  257. params: {
  258. pageName: row.punishOrderId,
  259. pageType: 'detail',
  260. pageCode: row.punishOrderId
  261. }
  262. })
  263. } else {
  264. this.$router.push({
  265. name: 'workOrderPool',
  266. params: {
  267. pageName: row.orderBaseId,
  268. pageType: 'detail',
  269. pageCode: row.orderBaseId,
  270. pagePam: 'SettleAccounts'
  271. }
  272. })
  273. }
  274. }
  275. }
  276. })
  277. },
  278. poolData1() {
  279. this.formDialogType = 0
  280. this.openForm()
  281. },
  282. poolData2() {
  283. if (this.recordSelected.length == 0) {
  284. return this.$message.warning('请至少勾选一条数据!')
  285. }
  286. this.poolMore(
  287. this.recordSelected.map(item => {
  288. return item.id
  289. })
  290. )
  291. },
  292. openForm() {
  293. this.formDialog = true
  294. },
  295. formCancel() {
  296. this.$refs.formRef.$refs.inlineForm.clearValidate()
  297. this.$data.formData = this.$options.data().formData
  298. this.formDialog = false
  299. },
  300. poolMore(ids) {
  301. this.$confirm('请确认是否批量汇总选中的数据, 是否继续?', '提示', {
  302. confirmButtonText: '确定',
  303. cancelButtonText: '取消',
  304. type: 'warning'
  305. }).then(() => {
  306. poolMore({
  307. ids
  308. }).then(res => {
  309. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  310. this.$refs.pageRef.refreshList()
  311. })
  312. })
  313. },
  314. formConfirm() {
  315. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  316. if (valid) {
  317. pool({
  318. starDate: this.formData.starDate + ' 00:00:00',
  319. endDate: this.formData.endDate + ' 23:59:59',
  320. month: this.formData.month
  321. }).then(res => {
  322. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  323. this.formCancel()
  324. this.$refs.pageRef.refreshList()
  325. })
  326. }
  327. })
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .tab {
  334. padding: 20px 20px 0 20px;
  335. }
  336. </style>