index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-05 11:28:51
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-01-11 15:09:48
  6. * @FilePath: \订单全流程管理系统\src\views\contract\index.vue
  7. -->
  8. <template>
  9. <div class="contract-container">
  10. <vab-query-form>
  11. <vab-query-form-top-panel>
  12. <el-form :inline="true" label-width="0px" :model="queryForm" @submit.native.prevent>
  13. <el-form-item prop="contractCode">
  14. <el-input
  15. v-model="queryForm.contractCode"
  16. clearable
  17. placeholder="合同编号"
  18. @keyup.enter.native="queryData" />
  19. </el-form-item>
  20. <el-form-item prop="contractName">
  21. <el-input
  22. v-model="queryForm.contractName"
  23. clearable
  24. placeholder="合同名称"
  25. @keyup.enter.native="queryData" />
  26. </el-form-item>
  27. <el-form-item prop="custId">
  28. <el-input v-model="queryForm.custName" clearable placeholder="客户名称" @keyup.enter.native="queryData" />
  29. </el-form-item>
  30. <el-form-item prop="custId">
  31. <el-input v-model="queryForm.nboName" clearable placeholder="项目名称" @keyup.enter.native="queryData" />
  32. </el-form-item>
  33. <el-form-item prop="custId">
  34. <el-select v-model="queryForm.approStatus" clearable placeholder="审批状态">
  35. <el-option v-for="item in approStatusOption" :key="item.id" :label="item.label" :value="item.id" />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
  40. </el-form-item>
  41. </el-form>
  42. </vab-query-form-top-panel>
  43. <vab-query-form-left-panel :span="12">
  44. <el-button icon="el-icon-plus" type="primary" @click="handleEdit()">新建</el-button>
  45. <el-button icon="el-icon-delete" type="danger" @click="handleDelete()">删除</el-button>
  46. </vab-query-form-left-panel>
  47. <vab-query-form-right-panel :span="12">
  48. <table-tool :check-list.sync="checkList" :columns="columns" />
  49. </vab-query-form-right-panel>
  50. </vab-query-form>
  51. <el-table v-loading="listLoading" :data="list" :height="height" @selection-change="setSelectRows">
  52. <el-table-column align="center" show-overflow-tooltip type="selection" />
  53. <el-table-column
  54. v-for="(item, index) in finallyColumns"
  55. :key="index"
  56. align="center"
  57. :label="item.label"
  58. :min-width="item.width"
  59. :prop="item.prop"
  60. show-overflow-tooltip
  61. :sortable="item.sortable">
  62. <template #default="{ row }">
  63. <el-button v-if="item.prop === 'custName'" class="link-button" type="text" @click="handleCustDetail(row)">
  64. {{ row.custName }}
  65. </el-button>
  66. <span v-else-if="item.prop === 'contractAmount'">
  67. {{ formatPrice(row.contractAmount) }}
  68. </span>
  69. <span v-else-if="item.label === '合同时间'">
  70. {{ parseTime(row.contractStartTime, '{y}-{m}-{d}') }}~{{ parseTime(row.contractEndTime, '{y}-{m}-{d}') }}
  71. </span>
  72. <el-button
  73. v-else-if="item.prop === 'contractName'"
  74. style="font-size: 14px"
  75. type="text"
  76. @click="handleContractDetail(row)">
  77. {{ row.contractName }}
  78. </el-button>
  79. <span v-else>{{ row[item.prop] }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column align="center" fixed="right" label="操作" width="120px">
  83. <template slot-scope="scope">
  84. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  85. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  86. <el-button type="text" @click="handleTransfer(scope.row)">转移</el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <el-pagination
  91. background
  92. :current-page="queryForm.pageNum"
  93. :layout="layout"
  94. :page-size="queryForm.pageSize"
  95. :total="total"
  96. @current-change="handleCurrentChange"
  97. @size-change="handleSizeChange" />
  98. <!-- 新增编辑客户弹窗 -->
  99. <Edit ref="edit" @contractSave="contractSave" />
  100. <!-- 转移合同 -->
  101. <Transfer ref="transfer" :contract-id="contractId" @transferSave="contractSave" />
  102. </div>
  103. </template>
  104. <script>
  105. import to from 'await-to-js'
  106. import contractApi from '@/api/contract'
  107. import Edit from './components/Edit'
  108. import TableTool from '@/components/table/TableTool'
  109. import Transfer from './components/Transfer'
  110. export default {
  111. name: 'OpenSea',
  112. components: {
  113. Edit,
  114. TableTool,
  115. Transfer,
  116. },
  117. data() {
  118. return {
  119. height: this.$baseTableHeight(2),
  120. approStatusOption: [
  121. { id: 1, label: '审批中' },
  122. { id: 2, label: '已拒绝' },
  123. { id: 3, label: '已通过' },
  124. ],
  125. contractId: 0, //当前合同id
  126. listLoading: false,
  127. layout: 'total, sizes, prev, pager, next, jumper',
  128. list: [],
  129. total: 0,
  130. queryForm: {
  131. pageNum: 1,
  132. pageSize: 10,
  133. contractCode: '', // 合同编号
  134. contractName: '', //合同名称
  135. custName: '', // 客户名称 ()
  136. nboName: '', //项目名称
  137. approStatus: '', //审批状态
  138. },
  139. selectRows: [], //选择的表格数据
  140. industryOptions: [], //客户行业
  141. levelOptions: [], //客户级别
  142. // 自定义列表
  143. checkList: [],
  144. columns: [
  145. {
  146. label: '合同编号',
  147. width: '160px',
  148. prop: 'contractCode',
  149. sortable: false,
  150. disableCheck: false,
  151. },
  152. {
  153. label: '合同名称',
  154. width: '280px',
  155. prop: 'contractName',
  156. sortable: false,
  157. disableCheck: false,
  158. },
  159. {
  160. label: '客户名称',
  161. width: '280px',
  162. prop: 'custName',
  163. sortable: false,
  164. disableCheck: false,
  165. },
  166. {
  167. label: '项目名称',
  168. width: '280px',
  169. prop: 'nboName',
  170. sortable: false,
  171. disableCheck: false,
  172. },
  173. {
  174. label: '合同类型',
  175. width: '100px',
  176. prop: 'contractType',
  177. sortable: false,
  178. disableCheck: false,
  179. },
  180. {
  181. label: '合同金额',
  182. width: '120px',
  183. prop: 'contractAmount',
  184. sortable: false,
  185. disableCheck: false,
  186. },
  187. {
  188. label: '合同时间',
  189. width: '180px',
  190. prop: 'distributorName',
  191. sortable: false,
  192. disableCheck: false,
  193. },
  194. {
  195. label: '审批状态',
  196. width: '100px',
  197. prop: 'approStatus',
  198. sortable: false,
  199. disableCheck: false,
  200. },
  201. {
  202. label: '销售工程师',
  203. width: '120px',
  204. prop: 'inchargeName',
  205. sortable: false,
  206. disableCheck: false,
  207. },
  208. {
  209. label: '公司签约人',
  210. width: '120px',
  211. prop: 'signatoryName',
  212. sortable: false,
  213. disableCheck: false,
  214. },
  215. {
  216. label: '客户签约人',
  217. width: '120px',
  218. prop: 'custSignatoryName',
  219. sortable: false,
  220. disableCheck: false,
  221. },
  222. {
  223. label: '经销商/代理商',
  224. width: '120px',
  225. prop: 'distributorName',
  226. sortable: false,
  227. disableCheck: false,
  228. },
  229. ],
  230. }
  231. },
  232. computed: {
  233. finallyColumns() {
  234. return this.columns.filter((item) => this.checkList.includes(item.label))
  235. },
  236. },
  237. mounted() {
  238. this.queryData()
  239. },
  240. methods: {
  241. async queryData() {
  242. this.listLoading = true
  243. const params = { ...this.queryForm }
  244. const [err, res] = await to(contractApi.getList(params))
  245. if (err) return (this.listLoading = false)
  246. this.list = res.data.list || []
  247. this.total = res.data.total
  248. this.listLoading = false
  249. },
  250. reset() {
  251. this.queryForm = {
  252. pageNum: 1,
  253. pageSize: 10,
  254. custCode: '', // 客户编码
  255. custName: '', //客户名称
  256. custIndustry: '', // 客户行业 ()
  257. custLevel: '', //客户级别
  258. }
  259. this.queryData()
  260. },
  261. handleSizeChange(val) {
  262. this.queryForm.pageSize = val
  263. this.queryData()
  264. },
  265. handleCurrentChange(val) {
  266. this.queryForm.pageNum = val
  267. this.queryData()
  268. },
  269. setSelectRows(val) {
  270. this.selectRows = val.map((item) => item.id)
  271. },
  272. // 客户编辑
  273. async handleEdit(row = null) {
  274. row ? this.$refs.edit.init(row.id) : this.$refs.edit.init()
  275. },
  276. // 合同详情
  277. handleContractDetail(row) {
  278. this.$router.push({
  279. path: '/contract/detail',
  280. query: {
  281. id: row.id,
  282. },
  283. })
  284. },
  285. // 客户详情
  286. handleCustDetail(row) {
  287. this.$router.push({
  288. path: '/customer/detail',
  289. query: {
  290. id: row.custId,
  291. },
  292. })
  293. },
  294. // 转移合同
  295. handleTransfer(row) {
  296. this.contractId = row.id
  297. this.$refs.transfer.open()
  298. },
  299. // 合同删除
  300. handleDelete(row = null) {
  301. let ids = row ? [row.id] : this.selectRows
  302. if (!ids[0]) {
  303. return
  304. }
  305. this.$confirm('确认删除?', '提示', {
  306. confirmButtonText: '确定',
  307. cancelButtonText: '取消',
  308. type: 'warning',
  309. })
  310. .then(async () => {
  311. const [err, res] = await to(contractApi.delContract({ id: ids }))
  312. if (err) return
  313. if (res.code == 200) {
  314. this.$message({
  315. type: 'success',
  316. message: '删除成功!',
  317. })
  318. this.queryData()
  319. }
  320. })
  321. .catch(() => {})
  322. },
  323. contractSave() {
  324. this.queryData()
  325. },
  326. },
  327. }
  328. </script>
  329. <style lang="scss" scoped>
  330. $base: '.contract-container';
  331. </style>