order.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!-- 订单 -->
  2. <template>
  3. <div class="order">
  4. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  5. <el-form-item label="客户名称">
  6. <el-select
  7. v-model="dataForm.customerId"
  8. remote
  9. filterable
  10. :remote-method="remoteCustomer"
  11. placeholder="请选择">
  12. <el-option
  13. v-for="item in optionsCustomer"
  14. :key="item.code"
  15. :label="item.value"
  16. :value="item.code">
  17. </el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="合同编码">
  21. <el-input v-model="dataForm.cusOrderCode" placeholder="合同编码" clearable></el-input>
  22. </el-form-item>
  23. <el-form-item label="创建日期">
  24. <el-date-picker
  25. v-model="dataForm.createTime"
  26. value-format="yyyy-MM-dd"
  27. type="date">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button @click="queryData()">查询</el-button>
  32. <el-button v-if="isAuth('order:ctl:save')" @click="addOrUpdateHandle(0, false)" type="primary">创建订单</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-table
  36. :data="dataList"
  37. border
  38. v-loading="dataListLoading"
  39. @selection-change="selectionChangeHandle"
  40. style="width: 100%;">
  41. <el-table-column
  42. label="序号"
  43. type="index"
  44. width="50"
  45. align="center">
  46. </el-table-column>
  47. <el-table-column
  48. prop="orderCode"
  49. header-align="center"
  50. align="center"
  51. min-width="180"
  52. label="订单编码">
  53. </el-table-column>
  54. <el-table-column
  55. prop="customerName"
  56. header-align="center"
  57. align="center"
  58. min-width="180"
  59. :show-overflow-tooltip="true"
  60. label="客户名称">
  61. </el-table-column>
  62. <el-table-column
  63. prop="cusOrderCode"
  64. header-align="center"
  65. align="center"
  66. min-width="120"
  67. label="客户订单编号">
  68. </el-table-column>
  69. <el-table-column
  70. prop="createTime"
  71. header-align="center"
  72. align="center"
  73. min-width="160"
  74. label="下单时间">
  75. </el-table-column>
  76. <el-table-column
  77. prop="contactDate"
  78. header-align="center"
  79. align="center"
  80. min-width="160"
  81. label="合同交期">
  82. </el-table-column>
  83. <el-table-column
  84. prop="state"
  85. header-align="center"
  86. align="center"
  87. :formatter="formatState"
  88. label="当前状态">
  89. </el-table-column>
  90. <el-table-column
  91. prop="approver"
  92. header-align="center"
  93. align="center"
  94. :min-width="140"
  95. :show-overflow-tooltip="true"
  96. label="当前审批人">
  97. </el-table-column>
  98. <el-table-column
  99. prop="completeDate"
  100. header-align="center"
  101. align="center"
  102. min-width="160"
  103. label="订单完成时间">
  104. </el-table-column>
  105. <el-table-column
  106. prop="notes"
  107. header-align="center"
  108. align="center"
  109. min-width="100"
  110. :show-overflow-tooltip="true"
  111. label="备注">
  112. </el-table-column>
  113. <el-table-column
  114. fixed="right"
  115. header-align="center"
  116. align="center"
  117. width="150"
  118. label="操作">
  119. <template slot-scope="scope">
  120. <el-button v-if="isAuth('order:ctl:info')" type="text" size="small" @click="detailHandle(scope.row.orderId)">查看</el-button>
  121. <el-button v-if="isAuth('order:ctl:editor') && Number(scope.row.state) < 2" type="text" size="small" @click="addOrUpdateHandle(scope.row.orderId,false)">编辑</el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <el-pagination
  126. @size-change="sizeChangeHandle"
  127. @current-change="currentChangeHandle"
  128. :current-page="pageIndex"
  129. :page-sizes="[10, 20, 50, 100]"
  130. :page-size="pageSize"
  131. :total="totalPage"
  132. layout="total, sizes, prev, pager, next, jumper">
  133. </el-pagination>
  134. <!-- 弹窗, 新增 / 修改 -->
  135. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  136. <detail v-if="detailVisible" ref="detail"/>
  137. </div>
  138. </template>
  139. <script>
  140. import AddOrUpdate from './order-add-or-update'
  141. import Detail from './order-detail'
  142. import { getOrderList } from '@/api/sale'
  143. import { getCusList } from '@/api/cus'
  144. export default {
  145. name: 'order',
  146. components: {
  147. AddOrUpdate, Detail
  148. },
  149. created () {
  150. this.queryData()
  151. },
  152. data () {
  153. return {
  154. addOrUpdateVisible: false,
  155. detailVisible: false,
  156. dataForm: {},
  157. dataList: [],
  158. pageIndex: 1,
  159. pageSize: 10,
  160. totalPage: 0,
  161. dataListLoading: false,
  162. dataListSelections: [],
  163. optionsState: [
  164. {
  165. code: null, value: '全部'
  166. },
  167. {
  168. code: '0', value: '待提交'
  169. },
  170. {
  171. code: '1', value: '待审批'
  172. },
  173. {
  174. code: '2', value: '审批中'
  175. },
  176. {
  177. code: '3', value: '审批完成'
  178. },
  179. {
  180. code: '4', value: '审批不通过'
  181. }
  182. ],
  183. optionsCustomer: []
  184. }
  185. },
  186. methods: {
  187. // 查询
  188. queryData () {
  189. this.pageIndex = 1
  190. this.getDataList()
  191. },
  192. // 获取数据列表
  193. getDataList () {
  194. this.dataListLoading = true
  195. let params = {
  196. 'current': this.pageIndex,
  197. 'size': this.pageSize,
  198. 'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
  199. 'cusOrderCode': this.dataForm.cusOrderCode ? this.dataForm.cusOrderCode : null,
  200. 'customerId': this.dataForm.customerId ? this.dataForm.customerId : null,
  201. 'state': this.dataForm.state ? this.dataForm.state : null
  202. }
  203. getOrderList(params).then(({data}) => {
  204. if (data && data.code === '200') {
  205. this.dataList = data.data.records
  206. this.totalPage = Number(data.data.total)
  207. } else {
  208. this.dataList = []
  209. this.totalPage = 0
  210. }
  211. this.dataListLoading = false
  212. })
  213. },
  214. // 每页数
  215. sizeChangeHandle (val) {
  216. this.pageSize = val
  217. this.pageIndex = 1
  218. this.getDataList()
  219. },
  220. // 当前页
  221. currentChangeHandle (val) {
  222. this.pageIndex = val
  223. this.getDataList()
  224. },
  225. // 多选
  226. selectionChangeHandle (val) {
  227. this.dataListSelections = val
  228. },
  229. // 远程方法:获取客户列表
  230. async remoteCustomer (query) {
  231. if (!query) {
  232. query = ''
  233. }
  234. await getCusList({'customerName': query}).then(({data}) => {
  235. if (data && data.code === '200') {
  236. this.optionsCustomer = []
  237. data.data.records.forEach((item) => {
  238. this.optionsCustomer.push({
  239. code: item.customerId,
  240. value: item.customerName
  241. })
  242. })
  243. }
  244. })
  245. },
  246. // 新增 / 修改
  247. addOrUpdateHandle (id, disable) {
  248. this.addOrUpdateVisible = true
  249. this.$nextTick(() => {
  250. this.$refs.addOrUpdate.init(id, disable)
  251. })
  252. },
  253. // 转换属性“状态”
  254. formatState (row) {
  255. if (!row.state) return ''
  256. const item1 = this.optionsState.find((item) => item.code === row.state.toString())
  257. return item1 ? item1.value : ''
  258. },
  259. // 详情
  260. detailHandle (id) {
  261. this.detailVisible = true
  262. this.$nextTick(() => {
  263. this.$refs.detail.init(id)
  264. })
  265. }
  266. }
  267. }
  268. </script>
  269. <style scoped>
  270. </style>