list.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div>
  3. <FullPage title='派工单'
  4. :list='set_list'
  5. @init='init'
  6. @searchData='init'
  7. @changePage='changePage'
  8. @changeSize='changeSize'
  9. :loading='loading'
  10. :tableColums='computedTable'
  11. :tableData='tableData'
  12. :showPage='false'
  13. :page_index='page_index'
  14. :total='total'>
  15. <div slot='titleButton'>
  16. <!-- <Button v-if='persimissionData["批量打印"]||persimissionData.all'
  17. type="primary"
  18. ghost>批量打印</Button> -->
  19. </div>
  20. <div slot='navButton'>
  21. <Button v-if='persimissionData["表头设置"]||persimissionData.all'
  22. @click="setupTableHeader"
  23. type="primary"
  24. ghost
  25. icon='ios-cog'>表头设置</Button>
  26. </div>
  27. <template slot="basicTypeSet"
  28. slot-scope="{row}">
  29. <div>
  30. <span v-for="item in warningList"
  31. :key="item.id"
  32. :style="{color:item.color}"
  33. v-show="item.id==row.warning_state">{{item.title}}</span>
  34. </div>
  35. </template>
  36. <template slot='set'
  37. slot-scope='{row}'>
  38. <div>
  39. <a v-if='persimissionData["原材料预算"]||persimissionData.all'
  40. class="map-margin"
  41. @click="goOriginalPage(row)">原材料预算</a>
  42. <!-- <a v-if='persimissionData["打印派工单"]||persimissionData.all'
  43. class="map-margin">打印派工单</a> -->
  44. <a v-if='persimissionData["详情"]||persimissionData.all'
  45. class="map-margin"
  46. @click="goDetial(row)">详情</a>
  47. </div>
  48. </template>
  49. <template slot="pageSlot">
  50. <div class="pageSlotStyle">
  51. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  52. @on-page-size-change='changeSize'
  53. @on-change='changePage'
  54. :current='page_index'
  55. show-total
  56. :total="total"
  57. show-sizer
  58. :page-size='page_size' />
  59. </div>
  60. </template>
  61. </FullPage>
  62. </div>
  63. </template>
  64. <script>
  65. import { mapState } from 'vuex'
  66. export default {
  67. data () {
  68. return {
  69. tableColums: [
  70. { title: '项目编号', align: 'center', key: 'order_no', fixed: 'left', width: '200' },
  71. // {
  72. // title: '订单类型', align: 'center', key: 'renovation_type', minWidth: 150,
  73. // render: (h, params) => h('span', {}, params.row.renovation_type == 1 ? '工装' : '家装')
  74. // },
  75. { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 200 },
  76. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 100, slot: 'basicTypeSet', },
  77. {
  78. title: '派工开始时间', align: 'center', key: 'start_time', minWidth: 200,
  79. render: (h, params) => h('span', {}, this.func.replaceDate(params.row.start_time * 1, 1))
  80. },
  81. {
  82. title: '派工结束时间', align: 'center', key: 'end_time', minWidth: 200,
  83. render: (h, params) => h('span', {}, this.func.replaceDate(params.row.end_time * 1, 1))
  84. },
  85. // { title: '派工人员', align: 'center', key: 'nickname', minWidth: 200 },
  86. {
  87. title: '预估工期', align: 'center', key: 'predict_time', minWidth: 200,
  88. render: (h, params) => h('span', `${(params.row.predict_time / 8).toFixed(1)}天`)
  89. },
  90. { title: '操作', align: 'center', key: 'set', slot: 'set', fixed: 'right', width: '240' },
  91. ],
  92. tableData: [],
  93. page_index: 1,
  94. page_size: 10,
  95. total: 0,
  96. proxyObj: {},
  97. loading: false,
  98. tableheaders: [],
  99. //详情页返回保留搜索数据
  100. corssPageData: {},
  101. warningList: [],
  102. userList: []
  103. }
  104. },
  105. computed: {
  106. ...mapState(['persimissionData']),
  107. computedTable () {
  108. if (this.tableheaders.length < 1) {
  109. return this.tableColums
  110. }
  111. return this.func.computedHeader(this.tableheaders, this.tableColums)
  112. },
  113. set_list () {
  114. return [
  115. { title: '项目编号', name: 'Input', serverName: 'order_no', placeholder: '请输入订单编号', value: '' },
  116. {
  117. title: '派工状态', name: 'Select', placeholder: '请选择', serverName: 'state', value: '',
  118. option: [
  119. { label: '未生产', value: 0 },
  120. { label: '生产中', value: 1 },
  121. { label: '生产完成', value: 2 },
  122. ]
  123. },
  124. { title: '开始派工时间', name: 'Input', start_server: 'start_time', end_server: 'end_time', start_value: '', end_value: '', isDate: true, serverName: 'id2', start_placeholder: '开始日期', end_placeholder: '结束日期' },
  125. // {
  126. // title: '订单类型', name: 'Select', serverName: 'renovation_type', placeholder: '请选择订单类型', value: '',
  127. // option: [
  128. // { label: '工装', value: 1 },
  129. // { label: '家装', value: 0 },
  130. // ]
  131. // },
  132. { title: '紧急程度', name: 'Select', serverName: 'warning_state', placeholder: '请选择', value: '', optionName: 'title', optionValue: 'id', option: this.warningList },
  133. { title: '项目名称', name: 'Input', serverName: 'residential_name', placeholder: '请输入项目名称', value: '' },
  134. // {
  135. // title: '派工人员', name: 'Select', serverName: 'user_id', placeholder: '请选择派工人员', optionName: 'nickname', optionValue: 'id', value: '',
  136. // option: this.userList
  137. // },
  138. ]
  139. }
  140. },
  141. created () {
  142. // 获取紧急程度
  143. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  144. // 获取用户列表
  145. this.axios({ method: 'get', url: '/api/employee_list', }).then((res) => { this.userList = res.data }).catch((err) => { });
  146. },
  147. beforeRouteEnter (to, from, next) {
  148. next(vm => {
  149. if (from.path != '/cms/productionorderlist/dispatchlist/confirm') {
  150. localStorage.removeItem('corssPageData')
  151. } else {
  152. vm.firstEnter = 1
  153. vm.page_index = JSON.parse(localStorage.getItem('corssPageData')).page_index
  154. vm.page_size = JSON.parse(localStorage.getItem('corssPageData')).page_size
  155. }
  156. });
  157. },
  158. beforeRouteLeave (to, from, next) {
  159. if (to.path == '/cms/productionorderlist/dispatchlist/confirm') {
  160. this.corssPageData = {
  161. 'order_no': this.set_list[0].value,
  162. 'state': this.set_list[1].value,
  163. 'start_time': this.set_list[2].start_value,
  164. 'end_time': this.set_list[2].end_value,
  165. // 'renovation_type': this.set_list[3].value,
  166. 'warning_state': this.set_list[3].value,
  167. 'residential_name': this.set_list[4].value,
  168. // 'user_id': this.set_list[6].value,
  169. 'page_index': this.page_index,
  170. 'page_size': this.page_size
  171. }
  172. localStorage.setItem('corssPageData', JSON.stringify(this.corssPageData))
  173. }
  174. next(vm => {
  175. });
  176. },
  177. methods: {
  178. init (row) {
  179. row.page_index = this.page_index;
  180. row.page_size = this.page_size;
  181. if (this.firstEnter == 1) {
  182. this.corssPageData = JSON.parse(localStorage.getItem('corssPageData'))
  183. row = this.corssPageData
  184. this.proxyObj = row
  185. this.set_list[0].value = row.order_no
  186. this.set_list[1].value = row.state
  187. this.set_list[2].value = row.start_time
  188. this.set_list[2].value = row.end_time
  189. // this.set_list[3].value = row.renovation_type
  190. this.set_list[3].value = row.warning_state
  191. this.set_list[4].value = row.residential_name
  192. // this.set_list[6].value = row.user_id
  193. this.firstEnter++
  194. this.$nextTick(() => {
  195. this.page_index = row.page_index
  196. this.page_size = row.page_size
  197. })
  198. } else {
  199. this.proxyObj = row
  200. }
  201. this.getData(row)
  202. },
  203. getData (row) {
  204. this.loading = true;
  205. this.axios('/api/orders_dispatch_list', { params: row }).then(res => {
  206. this.loading = false;
  207. if (res.code == 200) {
  208. this.tableData = res.data.data;
  209. this.total = res.data.total;
  210. this.tableheaders = res.data.tableSet || []
  211. }
  212. })
  213. },
  214. changePage (e) {
  215. this.page_index = e;
  216. this.proxyObj.page_index = this.page_index;
  217. this.getData(this.proxyObj)
  218. },
  219. changeSize (e) {
  220. this.page_size = e;
  221. this.proxyObj.page_size = this.page_size;
  222. this.getData(this.proxyObj)
  223. },
  224. goDetial (row) {
  225. console.log(1)
  226. this.$router.push({
  227. // path:'/cms/productionorderlist/dispatchlist/details',
  228. path: '/cms/productionorderlist/dispatchlist/confirm',
  229. query: {
  230. order_no: row.order_no,
  231. }
  232. })
  233. },
  234. goOriginalPage (row) {
  235. this.$router.push({
  236. path: '/cms/rawmateria/index',
  237. query: {
  238. order_no: row.order_no,
  239. type: 6,
  240. residential_name: row.residential_name
  241. }
  242. })
  243. },
  244. setupTableHeader () {
  245. this.tableheaders.length < 1 ? this.tableheaders = this.tableColums.reduce((pre, cur) => pre.concat(cur.key), []) : ''
  246. this.$setTableheader({
  247. list: this.tableColums,
  248. selects: this.tableheaders,
  249. then: (result) => {
  250. this.tableheaders = result
  251. this.axios.post('/api/update/table', { id: this.$route.query.id, result }).then(res => {
  252. if (res.code == 200) {
  253. this.$Message.success(res.msg)
  254. }
  255. })
  256. }
  257. })
  258. },
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .pageSlotStyle {
  264. display: flex;
  265. justify-content: center;
  266. margin-top: 40px;
  267. }
  268. </style>