index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title+'-列表', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <template-page v-if="activeKey == 'list'" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  5. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  6. :operation="operation()" :exportList="exportList">
  7. </template-page>
  8. <div v-if="~['remark'].indexOf(activeKey)">
  9. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  10. <zj-form-module title="" label-width="100px" :showPackUp="false"
  11. :form-data="formData" :form-items="formItems">
  12. </zj-form-module>
  13. </zj-form-container>
  14. <div slot="footer" class="dialog-footer">
  15. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  16. <el-button size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
  17. </div>
  18. </div>
  19. </template>
  20. </zj-tab-page>
  21. </template>
  22. <script>
  23. import TemplatePage from '@/components/template/template-page-1.vue'
  24. import import_mixin from '@/components/template/import_mixin.js'
  25. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  26. import { orderShareListPageV2, orderSharePageExport, settlement, saveRemark } from "@/api/settlement";
  27. import operation_mixin from '@/components/template/operation_mixin.js'
  28. export default {
  29. components: { TemplatePage },
  30. mixins: [import_mixin,operation_mixin],
  31. data() {
  32. return {
  33. // 事件组合
  34. optionsEvensGroup: [],
  35. // 表格属性
  36. tableAttributes: {
  37. // 启用勾选列
  38. selectColumn: false
  39. },
  40. // 表格事件
  41. tableEvents: {
  42. 'selection-change': this.selectionChange
  43. },
  44. // 勾选选中行
  45. recordSelected: [],
  46. /** 表单变量 */
  47. formDialogType: 0,
  48. formDialogTitles: ["备注"],
  49. formDialog: false,
  50. formData: {
  51. remark: '',
  52. },
  53. formType: 'add',
  54. formVisible: false,
  55. }
  56. },
  57. computed: {
  58. // 更多参数
  59. moreParameters() {
  60. return []
  61. },
  62. formItems() {
  63. return [{
  64. md: 24,
  65. isShow: true,
  66. name: 'el-input',
  67. attributes: { placeholder: '请输入', type: "textarea", maxlength: "100",rows: 5 },
  68. formItemAttributes: {
  69. label: '备注',
  70. prop: 'remark',
  71. rules: [...required]
  72. }
  73. }]
  74. }
  75. },
  76. methods: {
  77. // 列表请求函数
  78. getList: orderShareListPageV2,
  79. // 列表导出函数
  80. exportList: orderSharePageExport,
  81. // 表格列解析渲染数据更改
  82. columnParsing(item, defaultData) {
  83. if (item.jname === 'orderId') {
  84. defaultData.render = (h, { row, index, column }) => {
  85. return (
  86. <div style="padding:0 6px;cursor: pointer;" class={{ 'text-view': true, 'text-view-copy': column.isCopy }}>
  87. <span style="color:#008dd4;" onClick={() => {
  88. this.$router.push({
  89. name: "order_detail",
  90. params: {
  91. pageName: row.orderId,
  92. pageType: 'detail',
  93. pageCode: row.orderId
  94. },
  95. query: {
  96. id: row.orderId,
  97. orderId: row.orderId
  98. }
  99. })
  100. }}>{row.orderId}</span>
  101. {(column.isCopy && row.orderId) ? (
  102. <i
  103. style="color:#008dd4;"
  104. class={['el-icon-document-copy', column.columnCopyClass]}
  105. data-clipboard-text={row[column.columnAttributes.prop]}
  106. ></i>
  107. ) : null}
  108. </div>
  109. )
  110. }
  111. defaultData.columnAttributes.width = 200
  112. }
  113. return defaultData
  114. },
  115. // 监听勾选变化
  116. selectionChange(data) {
  117. this.recordSelected = data
  118. },
  119. // 表格操作列
  120. operation() {
  121. return this.operationBtn({
  122. remark: {
  123. btnType: 'text',
  124. click: ({ row, index, column }) => {
  125. Object.assign(this.formData, row)
  126. this.formDialogType = 0
  127. this.openForm('remark',row)
  128. }
  129. },
  130. account: {
  131. conditions: ({ row, index, column }) => {
  132. return row.orderStatus === 'OVER' && ~["EXCEPTION", "ING"].indexOf(row.status)
  133. },
  134. btnType: 'text',
  135. prompt: '是否确定结算?',
  136. click: ({ row, index, column }) => {
  137. settlement({
  138. orderId: row.orderId
  139. }).then(res => {
  140. this.$message({ type: 'success', message: `结算成功!` })
  141. this.$refs.pageRef.refreshList()
  142. })
  143. }
  144. },
  145. })
  146. },
  147. openForm(type) {
  148. this.$refs.tabPage.addTab({
  149. // 对应显示的模块
  150. activeKey: type,
  151. // 唯一标识
  152. key: type,
  153. // 页签名称
  154. label: ({ remark: "备注" })[type],
  155. // 打开时事件
  156. triggerEvent: () => {
  157. this.formCancel()
  158. this.$nextTick(()=>{
  159. this.formType = type
  160. this.formVisible = true
  161. })
  162. },
  163. // 关闭时事件
  164. closeEvent: () => {
  165. this.formCancel()
  166. }
  167. })
  168. },
  169. formCancel() {
  170. this.formVisible = false
  171. this.$refs?.formRef?.resetFields()
  172. this.$data.formRef = this.$options.data().formRef
  173. },
  174. formConfirm(cancel) {
  175. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  176. if (valid) {
  177. ([saveRemark][this.formDialogType])(this.formData).then(res => {
  178. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  179. cancel('list')
  180. this.$refs.pageRef.refreshList()
  181. })
  182. }
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped></style>