list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <div>
  3. <FullPage title='测量订单列表'
  4. :list='set_list'
  5. @init='init'
  6. :loading='loading'
  7. @searchData='searchData'
  8. @selectTable='selectTable'
  9. @changePage='changePage'
  10. @changeSize='changeSize'
  11. :tableColums='tableColums'
  12. :showPage='false'
  13. :tableData='tableData'
  14. :page_index='page_index'
  15. :total='total'>
  16. <div slot='titleButton'
  17. style="display:flex;">
  18. <Upload v-if='persimissionData["批量导入"]||persimissionData.all'
  19. name='your_file'
  20. :show-upload-list='false'
  21. :headers='headers'
  22. :on-error='uploadError'
  23. :on-success='uploadSuccess'
  24. :action="$store.state.ip+'/api/measure_orders_import'">
  25. <Button type="success"
  26. ghost
  27. icon='md-exit'
  28. style="margin-right:10px;">批量导入</Button>
  29. </Upload>
  30. <Button v-if='persimissionData["批量导出"]||persimissionData.all'
  31. @click="exportData"
  32. type="warning"
  33. ghost
  34. icon='md-return-left'
  35. style="margin-right:10px;">批量导出</Button>
  36. <Button @click="openModal(selects)"
  37. v-if='persimissionData["批量下生产"]||persimissionData.all'
  38. type="primary"
  39. ghost>批量下生产</Button>
  40. </div>
  41. <div slot='navButton'
  42. style="display:flex;">
  43. <Button v-if='persimissionData["表头设置"]||persimissionData.all'
  44. @click="setupTableHeader"
  45. type="primary"
  46. ghost
  47. icon='ios-cog'>表头设置</Button>
  48. </div>
  49. <template slot="basicTypeSet"
  50. slot-scope="{row}">
  51. <div>
  52. <span v-for="item in warningList"
  53. :key="item.id"
  54. :style="{color:item.color}"
  55. v-show="item.id==row.warning_state">{{item.title}}</span>
  56. </div>
  57. </template>
  58. <template slot='set'
  59. slot-scope='{row}'>
  60. <div>
  61. <a v-if='persimissionData["编辑"]||persimissionData.all'
  62. style="margin:0 5px"
  63. @click="goPage(row,0)">编辑</a>
  64. <a v-if='persimissionData["查看"]||persimissionData.all'
  65. style="margin:0 5px"
  66. @click="goPage(row,1)">查看</a>
  67. <a v-if='persimissionData["下生产"]||persimissionData.all'
  68. style="margin:0 5px"
  69. v-show="row.state<3"
  70. @click="openModal(row)">下生产</a>
  71. </div>
  72. </template>
  73. <template slot="pageSlot">
  74. <div class="pageSlotStyle">
  75. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  76. @on-page-size-change='changeSize'
  77. @on-change='changePage'
  78. :current='page_index'
  79. show-total
  80. :total="total"
  81. show-sizer
  82. :page-size='page_size' />
  83. </div>
  84. </template>
  85. </FullPage>
  86. </div>
  87. </template>
  88. <script>
  89. import { mapState } from 'vuex'
  90. export default {
  91. data () {
  92. return {
  93. tableColums: [
  94. { type: 'selection', fixed: 'left', title: '全选', key: 'selection', width: 90, align: 'center' },
  95. { title: '订单编号', align: 'center', key: 'order_no', width: '200' },
  96. {
  97. title: '测量状态', align: 'center', key: 'state', minWidth: 150,
  98. render: (h, params) => h('span', {},
  99. params.row.state == 0 ? '测量未审核'
  100. : (params.row.state == 1 ? '测量审核'
  101. : (params.row.state == 2 ? '测量中'
  102. : (params.row.state == 3 ? '生产审核中'
  103. : (params.row.state == 4 ? '生产通过'
  104. : (params.row.state == 5 ? '到生产计划' : '完成')))))
  105. )
  106. },
  107. {
  108. title: '测量单号', align: 'center', key: 'oa_order_no', minWidth: 200,
  109. render: (h, params) => h('span', {}, params.row.oa_order_no || params.row.order_no)
  110. },
  111. {
  112. title: '测量确认率', align: 'center', minWidth: 150, key: 'measure_rate',
  113. render: (h, params) => h('span', {}, (((params.row.measure_rate * 1).toFixed(2)) * 100) + '%')
  114. },
  115. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 100, slot: 'basicTypeSet', },
  116. { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 200 },
  117. { title: '地址', align: 'center', key: 'address', minWidth: 200 },
  118. { title: '客户姓名', align: 'center', key: 'client_name', minWidth: 100 },
  119. { title: '电话', align: 'center', key: 'mobile', minWidth: 150 },
  120. // {
  121. // title: '订单类型', align: 'center', key: 'order_type', minWidth: 100,
  122. // render: (h, params) => h('span', {}, params.row.order_type == 1 ? '工装' : '家装')
  123. // },
  124. {
  125. title: '测量开始时间', align: 'center', minWidth: 200, key: 'measure_start_time',
  126. render: (h, params) => h('span', {}, this.func.replaceDate(params.row.measure_start_time * 1, 1))
  127. },
  128. {
  129. title: '测量结束时间', align: 'center', minWidth: 200, key: 'measure_end_time',
  130. render: (h, params) => h('span', {}, this.func.replaceDate(params.row.measure_end_time * 1, 1))
  131. },
  132. {
  133. title: '实际完成时间', align: 'center', minWidth: 200, key: 'measure_time',
  134. render: (h, params) => h('span', {}, params.row.measure_time ? this.func.replaceDate(params.row.measure_time * 1) : '')
  135. },
  136. {
  137. title: '订单状态', align: 'center', minWidth: 100, key: 'sub_state',
  138. render: (h, params) => h('span', {}, params.row.sub_state == 0 ? '测量未审核' : (params.row.sub_state == 1 ? '测量审核' :
  139. (params.row.sub_state == 2 ? '测量通过' : (params.row.sub_state == 3 ? '生产审核中' : (params.row.sub_state == 4 ? '生产通过' : '到生产计划')))))
  140. },
  141. { title: '备注', align: 'center', key: 'remark', minWidth: 200 },
  142. { title: '操作', align: 'center', key: 'set', slot: 'set', width: '200', fixed: 'right' },
  143. ],
  144. tableData: [],
  145. page_index: 1,
  146. page_size: 10,
  147. total: 0,
  148. proxyObj: {},
  149. planInfo: {
  150. order_no: null,
  151. start_time: '',
  152. end_time: ''
  153. },
  154. loading: false,
  155. headers: { 'Authorization': localStorage.getItem('token') },
  156. selects: [],
  157. tableheaders: [],
  158. //详情页返回保留搜索数据
  159. corssPageData: localStorage.getItem('corssPageData') ? JSON.parse(localStorage.getItem('corssPageData')) : {},
  160. warningList: []
  161. }
  162. },
  163. beforeRouteEnter (to, from, next) {
  164. next(vm => {
  165. if (from.path != '/cms/measurementordermannage/edit') {
  166. localStorage.removeItem('corssPageData')
  167. } else {
  168. vm.firstEnter = 1
  169. }
  170. });
  171. },
  172. beforeRouteLeave (to, from, next) {
  173. if (to.path == '/cms/measurementordermannage/edit') {
  174. this.corssPageData.page_index = this.page_index,
  175. this.corssPageData.page_size = this.page_size,
  176. localStorage.setItem('corssPageData', JSON.stringify(this.corssPageData))
  177. } else {
  178. localStorage.removeItem('corssPageData')
  179. }
  180. next(vm => {
  181. });
  182. },
  183. created () {
  184. // 获取紧急程度
  185. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  186. },
  187. computed: {
  188. ...mapState(['persimissionData']),
  189. computedTable () {
  190. // if (this.tableheaders.length < 1) {
  191. return this.tableColums
  192. // }
  193. // return this.func.computedHeader(this.tableheaders, this.tableColums)
  194. },
  195. set_list () {
  196. return [
  197. { title: '订单编号', serverName: 'order_no', name: 'Input', value: '', placeholder: '请输入订单号' },
  198. {
  199. title: '紧急程度', name: 'Select', serverName: 'warning_state', optionValue: 'id', optionName: 'title', placeholder: '请选择', value: this.corssPageData ? this.corssPageData.warning_state : '',
  200. option: this.warningList
  201. },
  202. {
  203. title: '测量状态', name: 'Select', placeholder: '请选择', serverName: 'state', value: '',
  204. option: [
  205. { label: '全部', value: 99 },
  206. { label: '未测量', value: 3 },
  207. { label: '测量中', value: 2 },
  208. { label: '测量完成', value: 1 },
  209. ]
  210. },
  211. { title: '测量日期范围', start_server: 'start_time', end_server: 'end_time', start_value: '', end_value: this.corssPageData ? this.corssPageData.end_value : '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期' },
  212. { title: '测量单号', serverName: 'order_no', name: 'Input', value: '', placeholder: '请输入测量单号' },
  213. { title: '项目名称', serverName: 'residential_name', name: 'Input', value: '', placeholder: '请输入项目名称' },
  214. { title: '客户姓名', serverName: 'client_name', name: 'Input', value: '', placeholder: '请输入客户姓名' },
  215. {
  216. title: '订单状态', name: 'Select', placeholder: '请选择', serverName: 'sub_state', value: '',
  217. option: [
  218. { label: '全部', value: 0 },
  219. { label: '测量未审核', value: 1 },
  220. { label: '测量审核', value: 2 },
  221. { label: '测量通过', value: 3 },
  222. { label: '生产审核中', value: 4 },
  223. { label: '生产通过', value: 5 },
  224. { label: '到生产计划', value: 6 },
  225. { label: '完成', value: 7 },
  226. ]
  227. },
  228. // { title: '测量状态', serverName: 'order_no', name: 'Input', value: '', placeholder: '请输入测量状态' },
  229. ]
  230. }
  231. },
  232. methods: {
  233. init (row) {
  234. // row.page_index = this.page_index;
  235. // row.page_size = this.page_size;
  236. row.sub_state = 2;
  237. if (this.firstEnter == 1) {
  238. this.corssPageData = JSON.parse(localStorage.getItem('corssPageData'))
  239. row = this.corssPageData
  240. this.proxyObj = row
  241. this.searchData(row)
  242. } else {
  243. this.page_index = 1
  244. row.page_index = this.page_index;
  245. row.page_size = this.page_size;
  246. this.proxyObj = row
  247. this.getData(row)
  248. }
  249. },
  250. searchData (row) {
  251. if (this.firstEnter == 1) {
  252. this.page_index = this.corssPageData.page_index;
  253. this.page_size = this.corssPageData.page_size;
  254. this.set_list[0].value = this.corssPageData.order_no
  255. this.set_list[1].value = this.corssPageData.warning_state
  256. this.set_list[2].value = this.corssPageData.state
  257. this.set_list[3].start_value = this.corssPageData.start_time ? this.corssPageData.start_time : ''
  258. this.set_list[3].end_value = this.corssPageData.end_time ? this.corssPageData.end_time : ''
  259. this.corssPageData.type = this.$route.query.type
  260. this.getData(this.corssPageData)
  261. } else {
  262. this.page_index = 1
  263. row.page_index = this.page_index;
  264. row.page_size = this.page_size;
  265. this.corssPageData.order_no = this.set_list[0].value
  266. this.corssPageData.warning_state = this.set_list[1].value
  267. this.corssPageData.state = this.set_list[2].value
  268. this.corssPageData.start_time = this.func.setDate(this.set_list[3].start_value)
  269. this.corssPageData.end_time = this.func.setDate(this.set_list[3].end_value)
  270. this.proxyObj = row
  271. this.getData(row)
  272. }
  273. },
  274. getData (row) {
  275. this.loading = true;
  276. this.axios('/api/order_measure_list', { params: row }).then(res => {
  277. this.loading = false;
  278. this.firstEnter++
  279. this.tableData = res.data.data;
  280. this.total = res.data.total;
  281. this.tableheaders = res.data.tableSet || []
  282. })
  283. },
  284. changePage (e) {
  285. this.page_index = e;
  286. this.proxyObj.page_index = this.page_index;
  287. this.getData(this.proxyObj)
  288. },
  289. changeSize (e) {
  290. this.page_size = e;
  291. this.proxyObj.page_size = this.page_size;
  292. this.getData(this.proxyObj)
  293. },
  294. goPage (row, s) {
  295. const order_no = row ? row.id : '';
  296. const id = row ? row.id : ''
  297. this.$router.push({
  298. path: '/cms/measurementordermannage/edit',
  299. // path:'/cms/ordermannage/businessorderlist/decorationlist',
  300. query: {
  301. id: id,
  302. order_no: row.order_no,
  303. type: 'measure',
  304. editType: s ? 1 : 0
  305. }
  306. })
  307. },
  308. approvalDetails (row) {
  309. this.$router.push({
  310. path: '/cms/approval/examine',
  311. query: {
  312. order_no: row.oa_order_no || row.order_no
  313. }
  314. })
  315. },
  316. openModal (row) {
  317. if (Array.isArray(row)) {
  318. if (row.length < 1) { return this.$Message.warning('请选择一项') }
  319. this.planInfo.order_no = row.reduce((pre, cur, idx) => `${pre}${cur.order_no}${idx == row.length - 1 ? '' : ','}`, '')
  320. } else {
  321. this.planInfo.order_no = row.order_no;
  322. }
  323. this.downProduction({
  324. title: '下生产',
  325. type: 2,
  326. params: this.planInfo,
  327. then: (e) => { this.getData(this.proxyObj) },
  328. cancel: (e) => { },
  329. })
  330. },
  331. async exportData () {
  332. const res = await this.axios('/api/measure_orders_export', { params: { ...this.proxyObj } })
  333. if (res.code == 200) {
  334. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`
  335. location.href = url
  336. }
  337. },
  338. uploadSuccess (res) {
  339. if (res.code == 200) {
  340. this.$Message.success(res.msg || '上传成功')
  341. } else {
  342. this.$Message.warning(res.msg || '上传失败')
  343. }
  344. this.getData(this.proxyObj)
  345. },
  346. uploadError (err) {
  347. this.$Message.error(err.msg || '上传失败')
  348. },
  349. selectTable (e) {
  350. this.selects = e;
  351. },
  352. setupTableHeader () {
  353. this.tableheaders.length < 1 ? this.tableheaders = this.tableColums.reduce((pre, cur) => pre.concat(cur.key), []) : ''
  354. this.$setTableheader({
  355. list: this.tableColums,
  356. selects: this.tableheaders,
  357. then: (result) => {
  358. this.tableheaders = result
  359. this.axios.post('/api/update/table', { id: this.$route.query.id, result }).then(res => {
  360. if (res.code == 200) {
  361. this.$Message.success(res.msg)
  362. }
  363. })
  364. }
  365. })
  366. },
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. .nav {
  372. display: flex;
  373. justify-content: space-between;
  374. align-items: center;
  375. }
  376. .item-attr {
  377. display: flex;
  378. align-items: center;
  379. margin-bottom: 10px;
  380. }
  381. .pageSlotStyle {
  382. display: flex;
  383. justify-content: center;
  384. margin-top: 40px;
  385. }
  386. </style>