BST_list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <div>
  3. <FullPage title='生产订单列表'
  4. :list='set_list'
  5. @init='init'
  6. @searchData='searchData'
  7. @changePage='changePage'
  8. @changeSize='changeSize'
  9. @selectTable='selectTable'
  10. :tableColums='computedTable'
  11. :showPage='false'
  12. :tableData='tableData'
  13. :page_index='page_index'
  14. :total='total'>
  15. <div slot='titleButton'>
  16. <!-- <Button v-if='persimissionData["批量打印二维码"]||persimissionData.all'
  17. type="primary"
  18. style="margin-right:10px"
  19. ghost>批量打印二维码</Button> -->
  20. <!-- <Button @click="openModal(selects)"
  21. type="primary"
  22. ghost>批量下生产排产</Button> -->
  23. </div>
  24. <div slot='navButton'>
  25. <!-- <Button @click="setupTableHeader"
  26. v-if='persimissionData["表头设置"]||persimissionData.all'
  27. type="primary"
  28. ghost
  29. icon='ios-cog'>表头设置</Button> -->
  30. </div>
  31. <template slot="basicTypeSet"
  32. slot-scope="{row}">
  33. <div>
  34. <span v-for="item in warningList"
  35. :key="item.id"
  36. :style="{color:item.color}"
  37. v-show="item.id==row.warning_state">{{item.title}}</span>
  38. </div>
  39. </template>
  40. <template slot='set'
  41. slot-scope='{row}'>
  42. <div>
  43. <!-- <a v-if='persimissionData["原材料预算"]||persimissionData.all'
  44. style="margin:0 5px"
  45. @click="goOriginalPage(row)">原材料预算</a> -->
  46. <!-- <a v-if='persimissionData["打印二维码"]||persimissionData.all'
  47. style="margin:0 5px">打印二维码</a> -->
  48. <a v-if='persimissionData["详情"]||persimissionData.all'
  49. style="margin:0 5px"
  50. @click="goDetial(row)">详情</a>
  51. <!-- <a v-if='persimissionData["下生产计划"]||persimissionData.all'
  52. style="margin:0 5px"
  53. :disabled="row.state==2"
  54. @click="openModal(row)">下生产排产</a> -->
  55. <a :disabled="row.part_state != 0"
  56. style="margin:0 5px"
  57. @click="del(row)">删除</a>
  58. </div>
  59. </template>
  60. <template slot="pageSlot">
  61. <div class="pageSlotStyle">
  62. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  63. @on-page-size-change='changeSize'
  64. @on-change='changePage'
  65. :current='page_index'
  66. show-total
  67. :total="total"
  68. show-sizer
  69. :page-size='page_size' />
  70. </div>
  71. </template>
  72. </FullPage>
  73. <Modal width='35'
  74. title='下生产排产'
  75. :mask-closable="false"
  76. v-model="show">
  77. <Form
  78. ref='forms'
  79. :rules='rules'>
  80. <FormItem v-for="item in basics_procedure_list" :key="item.id" :label='`要求${item.title}完成的时间:`' style="margin-left:60px" >
  81. <DatePicker type="daterange" placeholder="请选择" style="width: 200px" v-model='item.time' transfer :options='options' @on-open-change='timeFocus($event,item)'></DatePicker>
  82. </FormItem>
  83. </Form>
  84. <div slot="footer"
  85. class="modal-footer">
  86. <Button @click="show=false">取消</Button>
  87. <Button @click="finishDataTrue"
  88. type='primary'>确认</Button>
  89. </div>
  90. </Modal>
  91. </div>
  92. </template>
  93. <script>
  94. import { mapState } from 'vuex'
  95. export default {
  96. data () {
  97. return {
  98. options:{},
  99. basics_procedure_list:[],
  100. rules: {
  101. time: [{ required: true, message: '请选择时间', }]
  102. },
  103. show:false,
  104. tableColums: [
  105. { type: 'selection', key: 'selection', title: '全选', fixed: 'left', width: 90, align: 'center' },
  106. { title: '项目编号', align: 'center', key: 'order_no', width: '200' },
  107. // {
  108. // title: '订单类型', align: 'center', key: 'order_type', width: '200',
  109. // render: (h, params) => {
  110. // return h('span', {}, params.row.order_type == 1 ? '工装' : '家装')
  111. // }
  112. // },
  113. // {
  114. // title: '生产订单编号', align: 'center', key: 'oa_order_no', minWidth: 200,
  115. // render: (h, params) => h('span', {}, params.row.oa_order_no || params.row.order_no)
  116. // },
  117. { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 200 },
  118. {
  119. title: '生产状态', align: 'center', key: 'state', minWidth: 150,
  120. render: (h, params) => h('span', {},
  121. params.row.state == 0 ? '未下计划'
  122. : (params.row.state == 1 ? '计划中'
  123. : (params.row.state >= 2 ? '计划完成' : '全部'))
  124. )
  125. },
  126. // { title: '地址', align: 'center', key: 'address', minWidth: 200 },
  127. // { title: '客户姓名', align: 'center', key: 'client_name', minWidth: 200 },
  128. // { title: '手机号', align: 'center', key: 'mobile', minWidth: 200 },
  129. // { title: '测量人员', align: 'center', key: 'nickname', minWidth: 200 },
  130. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 100, slot: 'basicTypeSet', },
  131. {
  132. title: '下单日期', align: 'center', minWidth: 200, key: 'crt_time',
  133. render: (h, params) => h('span', {}, this.func.replaceDate(params.row.crt_time * 1))
  134. },
  135. // {
  136. // title: '测量开始日期', align: 'center', minWidth: 200, key: 'measure_start_time',
  137. // render: (h, params) => h('span', {}, this.func.replaceDate(params.row.measure_start_time * 1, 1))
  138. // },
  139. // {
  140. // title: '测量结束日期', align: 'center', minWidth: 200, key: 'measure_end_time',
  141. // render: (h, params) => h('span', {}, this.func.replaceDate(params.row.measure_end_time * 1, 1))
  142. // },
  143. // {
  144. // title: '实际测量时间', align: 'center', minWidth: 200, key: 'measure_time',
  145. // render: (h, params) => h('span', {}, this.func.replaceDate(params.row.measure_time * 1))
  146. // },
  147. { title: '操作', align: 'center', key: 'set', slot: 'set', fixed: 'right', width: '320' },
  148. ],
  149. tableData: [],
  150. page_index: 1,
  151. page_size: 10,
  152. total: 0,
  153. planInfo: {
  154. order_no: null,
  155. start_time: '',
  156. end_time: '',
  157. state: 3,
  158. },
  159. selects: [],
  160. tableheaders: [],
  161. //详情页返回保留搜索数据
  162. corssPageData: localStorage.getItem('corssPageData') ? JSON.parse(localStorage.getItem('corssPageData')) : {},
  163. userList: [],
  164. warningList: [],
  165. order_no:'',
  166. }
  167. },
  168. beforeRouteEnter (to, from, next) {
  169. next(vm => {
  170. if (from.path != '/cms/productionorderlist/productionsorder/Decorationlist') {
  171. localStorage.removeItem('corssPageData')
  172. } else {
  173. vm.firstEnter = 1
  174. }
  175. });
  176. },
  177. beforeRouteLeave (to, from, next) {
  178. if (to.path == '/cms/productionorderlist/productionsorder/Decorationlist') {
  179. this.corssPageData.page_index = this.page_index,
  180. this.corssPageData.page_size = this.page_size,
  181. localStorage.setItem('corssPageData', JSON.stringify(this.corssPageData))
  182. } else {
  183. localStorage.removeItem('corssPageData')
  184. }
  185. next(vm => {
  186. });
  187. },
  188. created () {
  189. // 获取用户列表
  190. this.axios({ method: 'get', url: '/api/user', }).then((res) => { this.userList = res.data.data }).catch((err) => { });
  191. // 获取紧急程度
  192. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  193. },
  194. computed: {
  195. ...mapState(['persimissionData']),
  196. computedTable () {
  197. // if (this.tableheaders.length < 1) {
  198. return this.tableColums
  199. // }
  200. // return this.func.computedHeader(this.tableheaders, this.tableColums)
  201. },
  202. set_list () {
  203. return [
  204. { title: '项目编号', name: 'Input', serverName: 'order_no', placeholder: '请输入订单编号', value: '' },
  205. { title: '项目名称', name: 'Input', serverName: 'residential_name', placeholder: '请输入项目名称', value: '' },
  206. // {
  207. // title: '订单类型', name: 'Select', serverName: 'order_type', placeholder: '请选择', value: '',
  208. // option: [
  209. // { label: '工装', value: 1 },
  210. // { label: '家装', value: 0 }
  211. // ]
  212. // },
  213. // {
  214. // title: '测量人员', name: 'Select', serverName: 'type', optionName: 'nickname', optionValue: 'id', placeholder: '请选择', value: '',
  215. // option: this.userList
  216. // },
  217. // { title: '客户名字', name: 'Input', serverName: 'client_name', placeholder: '请输入', value: '' },
  218. // { title: '手机号', name: 'Input', serverName: 'mobile', placeholder: '请输入', value: '' },
  219. { title: '紧急程度', name: 'Select', serverName: 'warning_state', placeholder: '请选择', value: '', optionName: 'title', optionValue: 'id', option: this.warningList },
  220. {
  221. title: '生产状态', name: 'Select', placeholder: '请选择', serverName: 'state', value: '',
  222. option: [
  223. { label: '未下计划', value: 0 },
  224. { label: '计划中', value: 1 },
  225. { label: '计划完成', value: 2 },
  226. ]
  227. },
  228. { title: '下单日期范围', name: 'Input', start_server: 'start_time', end_server: 'end_time', start_value: '', end_value: '', isDate: true, serverName: 'id2', start_placeholder: '开始日期', end_placeholder: '结束日期' },
  229. ]
  230. }
  231. },
  232. methods: {
  233. timeFocus(e,row){
  234. if(e){
  235. let ids = [];
  236. this.axios.post('/api/bst_get_plan_time',{type:0,id:[row.id],ids,order_no:this.planInfo.order_no}).then(res=>{
  237. if(res.code == 200){
  238. let time = [];
  239. res.data.forEach(v=>{
  240. time.push(v*1000);
  241. })
  242. // console.log(Date.parse(new Date()))
  243. this.options = {
  244. disabledDate(date) {
  245. return date && (date.valueOf() < time[0]||date.valueOf()>time[1]);
  246. }
  247. }
  248. }
  249. })
  250. }
  251. },
  252. finishDataTrue(){
  253. let arr = [];
  254. this.basics_procedure_list.forEach(m=>{
  255. let obj = {};
  256. obj.id = m.id;
  257. obj.start_time =Date.parse(m.time[0]).toString().slice(0,10)||'';
  258. obj.end_time =Date.parse(m.time[1]).toString().slice(0,10)||'';
  259. arr.push(obj);
  260. })
  261. console.log(arr);
  262. this.axios.post('/api/orders_plan',{order_no:this.planInfo.order_no,time_list:{...arr}}).then(res=>{
  263. if(res.code==200){
  264. this.$Message.success(res.msg);
  265. this.show=false;
  266. this.getData(this.proxyObj);
  267. }
  268. })
  269. },
  270. // sendPlanInfo(){
  271. // if (!this.time[0]) {
  272. // return this.$Message.error('请选择起始时间')
  273. // }
  274. // if (this.time.length > 0) {
  275. // this.planInfo.start_time = new Date(this.time[0]).toLocaleDateString().replace(/\//g, "-")
  276. // this.planInfo.end_time = new Date(this.time[1]).toLocaleDateString().replace(/\//g, "-")
  277. // }
  278. // let url = '/api/orders_plan';
  279. // this.axios.post(url, this.planInfo).then(res => {
  280. // if (res.code == 200) {
  281. // this.$Message.success(res.msg)
  282. // this.show = false
  283. // this.getData(this.proxyObj)
  284. // }
  285. // })
  286. // },
  287. del(row){
  288. this.axios.get('/api/orders_produce_order_del',{params:{order_no:row.order_no}}).then(res=>{
  289. if(res.code == 200){
  290. this.$Message.success(res.msg);
  291. this.getData(this.proxyObj)
  292. }
  293. })
  294. },
  295. init (row) {
  296. // row.page_index = this.page_index;
  297. // row.page_size = this.page_size;
  298. if (this.firstEnter == 1) {
  299. this.corssPageData = JSON.parse(localStorage.getItem('corssPageData'))
  300. row = this.corssPageData
  301. this.proxyObj = row
  302. this.searchData(row)
  303. } else {
  304. this.page_index = 1
  305. row.page_index = this.page_index;
  306. row.page_size = this.page_size;
  307. this.proxyObj = row
  308. this.getData(row)
  309. }
  310. },
  311. searchData (row) {
  312. if (this.firstEnter == 1) {
  313. this.page_index = this.corssPageData.page_index;
  314. this.page_size = this.corssPageData.page_size;
  315. this.set_list[0].value = this.corssPageData.order_no
  316. // this.set_list[1].value = this.corssPageData.type
  317. this.set_list[1].value = this.corssPageData.client_name
  318. // this.set_list[3].value = this.corssPageData.mobile
  319. this.set_list[2].value = this.corssPageData.warning_state
  320. this.set_list[3].value = this.corssPageData.state
  321. this.set_list[4].start_value = this.corssPageData.start_time ? this.corssPageData.start_time : ''
  322. this.set_list[4].end_value = this.corssPageData.end_time ? this.corssPageData.end_time : ''
  323. this.corssPageData.type = this.$route.query.type
  324. this.getData(this.corssPageData)
  325. } else {
  326. this.page_index = 1
  327. row.page_index = this.page_index;
  328. row.page_size = this.page_size;
  329. this.corssPageData.order_no = this.set_list[0].value
  330. // this.corssPageData.type = this.set_list[1].value
  331. this.corssPageData.client_name = this.set_list[1].value
  332. // this.corssPageData.mobile = this.set_list[2].value
  333. this.corssPageData.warning_state = this.set_list[2].value
  334. this.corssPageData.state = this.set_list[3].value
  335. this.corssPageData.start_time = this.func.setDate(this.set_list[4].start_value)
  336. this.corssPageData.end_time = this.func.setDate(this.set_list[4].end_value)
  337. this.proxyObj = row
  338. this.getData(row)
  339. }
  340. },
  341. changePage (e) {
  342. this.page_index = e;
  343. this.proxyObj.page_index = this.page_index;
  344. this.getData(this.proxyObj)
  345. },
  346. changeSize (e) {
  347. this.page_size = e;
  348. this.proxyObj.page_size = this.page_size;
  349. this.getData(this.proxyObj)
  350. },
  351. getData (row) {
  352. this.axios('/api/orders_produce_order_list', { params: row }).then(res => {
  353. this.tableData = res.data.data;
  354. this.firstEnter++
  355. this.total = res.data.total;
  356. this.tableheaders = res.data.tableSet || []
  357. })
  358. },
  359. goDetial (row) {
  360. this.$router.push({
  361. path: '/cms/productionorderlist/productionsorder/bst_Decorationlist',
  362. query: {
  363. order_no: row.order_no,
  364. type: 'produce',
  365. oa_id:row.oa_id
  366. }
  367. })
  368. },
  369. openModal (row) {
  370. let order_no = [];
  371. let id = [];
  372. if (Array.isArray(row)) {
  373. if (row.length < 1) { return this.$Message.warning('请选择一项') }
  374. this.planInfo.order_no = row.reduce((pre, cur, idx) => `${pre}${cur.order_no}${idx == row.length - 1 ? '' : ','}`, '')
  375. row.forEach(v=>{
  376. order_no.push(v.order_no);
  377. id.push(v.id)
  378. })
  379. } else {
  380. this.planInfo.order_no = row.order_no;
  381. order_no.push(row.order_no);
  382. id.push(row.id)
  383. }
  384. this.axios.get('/api/basics_procedure_index').then(res=>{
  385. this.show = true;
  386. this.basics_procedure_list = res.data.data.filter(v=>{
  387. return v.type==1||v.type==4
  388. })
  389. })
  390. },
  391. goOriginalPage (row) {
  392. this.$router.push({
  393. path: '/cms/rawmateria/index',
  394. query: {
  395. order_no: row.order_no,
  396. type: 4,
  397. residential_name: row.residential_name
  398. }
  399. })
  400. },
  401. selectTable (e) {
  402. this.selects = e;
  403. },
  404. setupTableHeader () {
  405. this.tableheaders.length < 1 ? this.tableheaders = this.tableColums.reduce((pre, cur) => pre.concat(cur.key), []) : ''
  406. this.$setTableheader({
  407. list: this.tableColums,
  408. selects: this.tableheaders,
  409. then: (result) => {
  410. this.tableheaders = result
  411. this.axios.post('/api/update/table', { id: this.$route.query.id, result }).then(res => {
  412. if (res.code == 200) {
  413. this.$Message.success(res.msg)
  414. }
  415. })
  416. }
  417. })
  418. },
  419. }
  420. }
  421. </script>
  422. <style lang="scss" scoped>
  423. .pageSlotStyle {
  424. display: flex;
  425. justify-content: center;
  426. margin-top: 40px;
  427. }
  428. </style>