list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="purchase_order">
  3. <Toptitle title="采购列表">
  4. <slot name="titleButton">
  5. <Button type="primary"
  6. @click="handleGoPage(1,'')"
  7. style="margin-right:10px;">新增</Button>
  8. <!-- <Button @click="handleCodeRule"
  9. type="primary"
  10. ghost
  11. style="margin-right:10px;">编码规则</Button> -->
  12. </slot>
  13. </Toptitle>
  14. <div class="purchase_order_search">
  15. <Form :label-width="90"
  16. :model="searchData">
  17. <FormItem label="订单号:">
  18. <Input type="text"
  19. size="small"
  20. v-model="searchData.order_no"
  21. style="width: 150px"
  22. clearable
  23. placeholder="订单号" />
  24. </FormItem>
  25. <FormItem label="项目名称:">
  26. <Input type="text"
  27. size="small"
  28. clearable
  29. v-model="searchData.project_title"
  30. style="width: 150px"
  31. placeholder="项目名称" />
  32. </FormItem>
  33. <FormItem label="供应商名称:">
  34. <Input type="text"
  35. size="small"
  36. v-model="searchData.supply_title"
  37. style="width: 150px"
  38. clearable
  39. placeholder="供应商名称" />
  40. </FormItem>
  41. <FormItem label="采购类型:">
  42. <Select v-model="searchData.type_id"
  43. size="small"
  44. clearable
  45. filterable
  46. label-in-value
  47. style="width: 150px">
  48. <Option v-for="(sitem) in purchaseTypeList"
  49. :key="sitem.id"
  50. :label="sitem.title"
  51. :value="sitem.id">
  52. </Option>
  53. </Select>
  54. </FormItem>
  55. <FormItem label="提交人:">
  56. <Select v-model="searchData.user_id"
  57. size="small"
  58. clearable
  59. style="width: 150px">
  60. <Option v-for="(sitem) in userList"
  61. :key="sitem.id"
  62. :label="sitem.nickname"
  63. :value="sitem.id">
  64. </Option>
  65. </Select>
  66. </FormItem>
  67. <FormItem label="订单状态:">
  68. <Select v-model="searchData.lock"
  69. size="small"
  70. clearable
  71. style="width: 150px">
  72. <Option label='正常'
  73. :value=0 />
  74. <Option label='已关闭'
  75. :value=1 />
  76. </Select>
  77. </FormItem>
  78. <FormItem label="审批状态:">
  79. <Select v-model="searchData.state"
  80. size="small"
  81. clearable
  82. style="width: 150px">
  83. <Option label='未提交'
  84. :value=0 />
  85. <Option label='审核中'
  86. :value=1 />
  87. <Option label='通过'
  88. :value=2 />
  89. <Option label='驳回'
  90. :value=3 />
  91. </Select>
  92. </FormItem>
  93. <FormItem label="制单时间:">
  94. <DatePicker type="date"
  95. size="small"
  96. style="width: 150px"
  97. placeholder="年/月/日"
  98. v-model="searchData.start_time"></DatePicker>
  99. </FormItem>
  100. <FormItem label="~">
  101. <DatePicker type="date"
  102. size="small"
  103. style="width: 150px"
  104. placeholder="年/月/日"
  105. v-model="searchData.end_time"></DatePicker>
  106. </FormItem>
  107. <FormItem>
  108. <Button type="primary"
  109. size="small"
  110. @click="initData(searchData)"
  111. style="margin-right:10px;">搜索</Button>
  112. </FormItem>
  113. </Form>
  114. </div>
  115. <div class="purchase_order_content">
  116. <div class="purchase_order_content_table">
  117. <Table :columns="tableColumns"
  118. border
  119. :max-height="500"
  120. :data="historyTableData">
  121. <template slot="setSlot"
  122. slot-scope="{row,index}">
  123. <a style="margin:0 5px"
  124. @click="handleSet(2,row,index)">详情</a>
  125. <a style="margin:0 5px"
  126. :disabled="row.state==1||row.state==2"
  127. @click="handleSet(3,row,index)">编辑</a>
  128. <a style="margin:0 5px"
  129. :disabled="row.state==1||row.state==2"
  130. @click="handleSet(4,row,index)">删除</a>
  131. <a style="margin:0 5px"
  132. :disabled="row.state==1||row.state==2"
  133. @click="handleSet(5,row,index)">提交</a>
  134. </template>
  135. </Table>
  136. <div class="purchase_order_content_page">
  137. <Page :page-size-opts="[10, 20, 30, 40,100]"
  138. @on-page-size-change='changeSize'
  139. @on-change='changePage'
  140. :current='pageIndex'
  141. show-total
  142. :total="total"
  143. show-sizer
  144. :page-size='pageSize' />
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  152. // 例如:import 《组件名称》 from '《组件路径》';
  153. export default {
  154. name: 'PurchasingOrderList',
  155. components: {
  156. },
  157. props: {},
  158. // import引入的组件需要注入到对象中才能使用
  159. data () {
  160. // 这里存放数据
  161. return {
  162. searchData: {
  163. order_no: '',
  164. project_title: '',
  165. supply_title: '',
  166. type_id: '',
  167. user_id: '',
  168. lock: '',
  169. state: '',
  170. start_time: '',
  171. end_time: '',
  172. },
  173. purchaseTypeList: [],
  174. tableColumns: [
  175. { title: '订单号', key: 'purchase_order_no', align: 'center', minWidth: 140 },
  176. { title: '项目名称', key: 'residential_name', align: 'center', minWidth: 140 },
  177. { title: '采购类型', key: 'type_title', align: 'center', minWidth: 140 },
  178. { title: '供应商名称', key: 'supply_title', align: 'center', minWidth: 140 },
  179. {
  180. title: '订单状态', key: 'lock', align: 'center', minWidth: 120,
  181. render: (h, params) => {
  182. const { row } = params
  183. const text = row.lock == 0 ? '正常' : '已关闭'
  184. return h('span', {}, text)
  185. }
  186. },
  187. { title: '提交人', key: 'nickname', align: 'center', minWidth: 100 },
  188. {
  189. title: '审批状态', key: 'state', align: 'center', minWidth: 140,
  190. render: (h, params) => {
  191. const { row } = params
  192. const text = row.state == 0 ? '未提交' : row.state == 1 ? '审核中' : row.state == 2 ? '通过' : '驳回'
  193. return h('span', {}, text)
  194. }
  195. },
  196. {
  197. title: '预计到货日期', key: 'arrive_time', align: 'center', minWidth: 140,
  198. render: (h, params) => {
  199. const { row } = params
  200. return h('span', {}, this.func.replaceDateNoHMS(row.arrive_time))
  201. }
  202. },
  203. {
  204. title: '制单日期', key: 'crt_time', align: 'center', minWidth: 140,
  205. render: (h, params) => {
  206. const { row } = params
  207. return h('span', {}, this.func.replaceDate(row.crt_time))
  208. }
  209. },
  210. { title: '操作', key: 'code', align: 'center', minWidth: 200, slot: 'setSlot' },
  211. ],
  212. tableData: [{}],
  213. historyTableData:[],
  214. pageIndex: 1,
  215. pageSize: 10,
  216. total: 0,
  217. userList: [],
  218. }
  219. },
  220. // 生命周期 - 创建完成(可以访问当前this实例)
  221. created () {
  222. // 获取采购类型
  223. this.axios({ method: 'get', url: '/api/basic_purchase_list', }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
  224. // 获取操作员
  225. this.axios('/api/user').then(res => this.userList = res.data.data)
  226. },
  227. // 生命周期 - 挂载完成(可以访问DOM元素)
  228. mounted () {
  229. this.initData()
  230. },
  231. beforeRouteLeave (to, from, next) {
  232. console.log(to.path != '/cms/PurchasingManage/PurchasingOrder/edit');
  233. if (to.path != '/cms/PurchasingManage/PurchasingOrder/edit') {
  234. this.$destroy()
  235. }
  236. next();
  237. },
  238. beforeRouteEnter(to,from,next){
  239. next(vm =>{
  240. if(from.name === 'PurchasingOrderEdit'){
  241. vm.initData()
  242. }
  243. })
  244. },
  245. methods: {
  246. initData () {
  247. let obj = JSON.parse(JSON.stringify(this.searchData))
  248. obj.start_time = parseInt(new Date(obj.start_time).getTime() / 1000) || ''
  249. obj.end_time = parseInt(new Date(obj.end_time).getTime() / 1000) || ''
  250. this.axios({
  251. method: 'get',
  252. url: '/api/purchase_list',
  253. params: {
  254. ...obj,
  255. }
  256. }).then((res) => {
  257. this.tableData = res.data.data
  258. this.historyTableData = this.tableData.slice(0,this.pageSize)
  259. this.total = res.data.total
  260. }).catch((err) => { });
  261. },
  262. handleSet (type, row, index) {
  263. // 1新增 2详情 3编辑 4删除 5提交
  264. switch (type) {
  265. case 1:
  266. case 2:
  267. case 3:
  268. this.handleGoPage(type, row.purchase_order_no,row.is_refer)
  269. break;
  270. case 4:
  271. this.$Modal.confirm({
  272. title: '确认删除?',
  273. content: '此操作无法恢复,请确认!',
  274. onOk: () => {
  275. this.axios({
  276. method: 'post',
  277. url: '/api/purchase_del',
  278. data: {
  279. purchase_order_no: row.purchase_order_no
  280. }
  281. }).then((res) => {
  282. this.$Message.success(res.msg)
  283. this.initData()
  284. }).catch((err) => { });
  285. },
  286. onCancel: () => { }
  287. })
  288. break;
  289. case 5:
  290. this.$Modal.confirm({
  291. title: '确认提交?',
  292. onOk: () => {
  293. this.axios({
  294. method: 'post',
  295. url: '/api/purchase_pull',
  296. data: {
  297. purchase_order_no: row.purchase_order_no,
  298. lock: row.lock,
  299. state: row.state + 1
  300. }
  301. }).then((res) => {
  302. this.$Message.success(res.msg)
  303. this.initData()
  304. }).catch((err) => { });
  305. },
  306. onCancel: () => { }
  307. })
  308. break;
  309. }
  310. },
  311. handleGoPage (type, purchase_order_no,is_refer) {
  312. this.$router.push({
  313. path: '/cms/PurchasingManage/PurchasingOrder/edit',
  314. query: {
  315. type,
  316. purchase_order_no,
  317. is_refer
  318. }
  319. })
  320. },
  321. changeSize (e) {
  322. this.pageSize = e;
  323. this.initData()
  324. },
  325. changePage (index) {
  326. this.pageIndex = index;
  327. let _start = (index - 1)*this.pageSize;
  328. let _end = index * this.pageSize;
  329. // this.initData()
  330. this.historyTableData = this.tableData.slice(_start,_end)
  331. }
  332. },
  333. // 监听属性 类似于data概念
  334. computed: {
  335. },
  336. // 监控data中的数据变化
  337. watch: {},
  338. beforeCreate () { }, // 生命周期 - 创建之前
  339. beforeMount () { }, // 生命周期 - 挂载之前
  340. beforeUpdate () { }, // 生命周期 - 更新之前
  341. updated () { }, // 生命周期 - 更新之后
  342. beforeDestroy () { }, // 生命周期 - 销毁之前
  343. destroyed () { }, // 生命周期 - 销毁完成
  344. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  345. }
  346. </script>
  347. <style lang='scss' scoped>
  348. .purchase_order_search {
  349. padding-top: 20px;
  350. /deep/.ivu-form {
  351. display: flex;
  352. justify-content: flex-start;
  353. flex-wrap: wrap;
  354. }
  355. /deep/.ivu-form-item {
  356. display: inline-block;
  357. width: 250px;
  358. }
  359. }
  360. .purchase_order_content {
  361. border-top: 1px solid #f4f4f4;
  362. margin-top: 20px;
  363. .purchase_order_content_btn {
  364. display: flex;
  365. justify-content: flex-end;
  366. padding: 20px 0;
  367. }
  368. .purchase_order_content_page {
  369. display: flex;
  370. justify-content: center;
  371. padding-top: 20px;
  372. }
  373. }
  374. </style>