Items.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="container">
  3. <el-tabs type="border-card" v-model="params.type" @tab-click="sousuo">
  4. <el-tab-pane label="所有产品" name="0"></el-tab-pane>
  5. <el-tab-pane label="未完成产品" name="1"></el-tab-pane>
  6. <el-tab-pane label="未完成统计" name="2"></el-tab-pane>
  7. <en-table-layout
  8. :tableData="tableData.data"
  9. :loading="loading"
  10. tooltip-effect="dark"
  11. @selection-change="handleSelectionChange"
  12. >
  13. <div slot="toolbar" class="inner-toolbar">
  14. <div v-if="params.type !== '2'" class="toolbar-btns">
  15. <el-button type="primary" @click="outExcel">导出当前页</el-button>
  16. <el-button type="warning" @click="outSelect">导出所选</el-button>
  17. </div>
  18. <div class="toolbar-search">
  19. <div style="float: left">
  20. <el-input v-model="params.order_name" placeholder="输入项目搜索" size="" clearable />
  21. </div>
  22. <div style="float: left">
  23. <el-input v-model="params.keyword" placeholder="输入产品名搜索" size="" clearable />
  24. </div>
  25. <el-button @click="sousuo">搜索</el-button>
  26. <!-- <el-input v-model="params.keyword" placeholder="输入项目搜索" size="mini" clearable />-->
  27. </div>
  28. </div>
  29. <template slot="table-columns">
  30. <el-table-column
  31. type="selection"
  32. width="55">
  33. </el-table-column>
  34. <!-- <el-table-column label="创建时间" :formatter="MixinUnixToDate" prop="create_time" sortable width="160"></el-table-column>-->
  35. <el-table-column v-if="params.type !== '2'" label="项目" min-width="180" show-overflow-tooltip>
  36. <template slot-scope="scope">
  37. <el-button round size="mini" @click="gotoOrder(scope.row.order_no)">{{scope.row.order_name}}</el-button>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="产品名称" min-width="220" show-overflow-tooltip>
  41. <template slot-scope="scope">
  42. <div class="goods-info">
  43. <div class="goods-image" style="margin: 0 20px;">
  44. <img :src="scope.row.image"/>
  45. </div>
  46. <div class="goods-name-box">
  47. <div class="goods-name">{{ scope.row.name }}</div>
  48. <el-tag type="warning" v-if="scope.row.type === '风尚版'">{{scope.row.type}}</el-tag>
  49. <el-tag v-else>{{scope.row.type}}</el-tag>
  50. </div>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="生产编码" prop="no" width="130">
  55. <template slot-scope="scope">
  56. <el-button round size="mini" @click="gotoGoods(scope.row.good_id)">{{ scope.row.no }}</el-button>
  57. </template>
  58. </el-table-column>
  59. <el-table-column v-if="params.type === '2'" label="总需数量" prop="count1"></el-table-column>
  60. <el-table-column v-if="params.type === '2'" label="已产数量" prop="count2"></el-table-column>
  61. <el-table-column v-if="params.type === '2'" label="需产数量">
  62. <template slot-scope="scope">
  63. <span>{{scope.row.count1 - scope.row.count2}}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column v-if="params.type !== '2'" label="数量" prop="qty"></el-table-column>
  67. <el-table-column v-if="params.type !== '2'" label="已产数量" prop="produced_qty"></el-table-column>
  68. <el-table-column v-if="params.type !== '2'" label="需产数量">
  69. <template slot-scope="scope">
  70. <span>{{scope.row.qty - scope.row.produced_qty}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column v-if="params.type !== '2'" label="要求发货日期" :formatter="MixinUnixToDay" prop="ship_date_required" sortable width="160"></el-table-column>
  74. <el-table-column v-if="params.type !== '2'" label="生产状态" prop="produce_status"></el-table-column>
  75. <el-table-column label="操作" width="100" fixed="right">
  76. <template slot-scope="scope">
  77. <el-button v-if="params.type !== '2'" size="mini" type="primary" @click="handleDetail(scope.row.id)">明细</el-button>
  78. <el-button v-else size="mini" type="primary" @click="handleDetail2(scope.row)">明细</el-button>
  79. </template>
  80. </el-table-column>
  81. </template>
  82. <el-pagination
  83. v-if="tableData"
  84. slot="pagination"
  85. @size-change="handlePageSizeChange"
  86. @current-change="handlePageCurrentChange"
  87. :current-page="tableData.page_no"
  88. :page-sizes="[10, 20, 50, 100]"
  89. :page-size="tableData.page_size"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. :total="tableData.data_total">
  92. </el-pagination>
  93. </en-table-layout>
  94. </el-tabs>
  95. <el-drawer :title="'《' + myTitle + '》产品明细'" :visible.sync="drawerShow" size="70%">
  96. <en-table-layout
  97. :tableData="tableData2.data"
  98. >
  99. <div slot="toolbar" class="inner-toolbar">
  100. <div class="toolbar-search">
  101. <div style="float: left">
  102. <el-input v-model="params2.order_name" placeholder="输入项目名搜索" size="" clearable />
  103. </div>
  104. <el-button @click="sousuo2">搜索</el-button>
  105. </div>
  106. </div>
  107. <template slot="table-columns">
  108. <el-table-column type="index" label="序号" width="55"></el-table-column>
  109. <el-table-column label="项目" width="180" show-overflow-tooltip>
  110. <template slot-scope="scope">
  111. <el-button round size="mini" @click="gotoOrder(scope.row.order_no)">{{scope.row.order_name}}</el-button>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="生产编码" prop="no" width="150" show-overflow-tooltip>
  115. <template slot-scope="scope">
  116. <el-button round size="mini" @click="gotoGoods(scope.row.good_id)">{{ scope.row.no }}</el-button>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="数量" prop="qty"></el-table-column>
  120. <el-table-column label="已产数量" prop="produced_qty"></el-table-column>
  121. <el-table-column label="要求发货日期" :formatter="MixinUnixToDay" prop="ship_date_required" sortable width="160"></el-table-column>
  122. <el-table-column label="技术" prop="tech_name"></el-table-column>
  123. <el-table-column label="生产" prop="produce_name"></el-table-column>
  124. <el-table-column label="生产状态" prop="produce_status"></el-table-column>
  125. </template>
  126. <el-pagination
  127. v-if="tableData2"
  128. slot="pagination"
  129. @size-change="handlePageSizeChange2"
  130. @current-change="handlePageCurrentChange2"
  131. :current-page="tableData2.page_no"
  132. :page-sizes="[10, 20, 50, 100]"
  133. :page-size="tableData2.page_size"
  134. layout="total, sizes, prev, pager, next, jumper"
  135. :total="tableData2.data_total">
  136. </el-pagination>
  137. </en-table-layout>
  138. </el-drawer>
  139. </div>
  140. </template>
  141. <script>
  142. import * as API_orderItems from '@/api/pjOrderItems.js'
  143. import { Foundation } from '~/ui-utils'
  144. import { getPageGroupList } from '../../api/pjOrderItems'
  145. export default {
  146. name: 'pjOrderItemsList',
  147. data() {
  148. return {
  149. /** 列表loading状态 */
  150. loading: false,
  151. /** 列表参数 */
  152. params: {
  153. page_no: 1,
  154. page_size: 10,
  155. type: 0
  156. },
  157. /** 商品列表数据 */
  158. tableData: '',
  159. multipleSelection: [],
  160. activeName: 0,
  161. drawerShow: false,
  162. tableData2: [],
  163. params2: {
  164. page_no: 1,
  165. page_size: 10,
  166. type: 1,
  167. good_id: 1
  168. },
  169. myTitle: ''
  170. }
  171. },
  172. mounted() {
  173. this.GET_List()
  174. },
  175. activated() {
  176. this.GET_List()
  177. },
  178. methods: {
  179. /** 分页大小发生改变 */
  180. handlePageSizeChange(size) {
  181. this.params.page_size = size
  182. this.GET_List()
  183. },
  184. /** 分页页数发生改变 */
  185. handlePageCurrentChange(page) {
  186. this.params.page_no = page
  187. this.GET_List()
  188. },
  189. GET_List() {
  190. this.loading = true
  191. if (this.params.type > 1) {
  192. API_orderItems.getPageGroupList(this.params).then(response => {
  193. this.loading = false
  194. this.tableData = response
  195. }).catch(() => (this.loading = false))
  196. } else {
  197. API_orderItems.getPageList(this.params).then(response => {
  198. this.loading = false
  199. this.tableData = response
  200. }).catch(() => (this.loading = false))
  201. }
  202. },
  203. /** 分页大小发生改变 */
  204. handlePageSizeChange2(size) {
  205. this.params2.page_size = size
  206. this.GET_List2()
  207. },
  208. /** 分页页数发生改变 */
  209. handlePageCurrentChange2(page) {
  210. this.params2.page_no = page
  211. this.GET_List2()
  212. },
  213. GET_List2() {
  214. this.loading = true
  215. API_orderItems.getPageList(this.params2).then(response => {
  216. this.loading = false
  217. this.tableData2 = response
  218. }).catch(() => (this.loading = false))
  219. },
  220. handleDetail(id) {
  221. this.drawerShow = false
  222. this.$router.push({ name: 'pjOrderItemDetail', params: { id: id, callback: this.GET_List }})
  223. },
  224. gotoOrder(orderNO) {
  225. this.drawerShow = false
  226. this.$router.push({ name: 'pjOrderEdit', params: { id: orderNO, callback: this.GET_List }})
  227. },
  228. gotoGoods(goodsCode) {
  229. this.drawerShow = false
  230. this.$router.push({ name: 'goodsDetail', params: { id: goodsCode }})
  231. },
  232. handleSelectionChange(val) {
  233. this.multipleSelection = val
  234. },
  235. outExcel() {
  236. const json = {
  237. sheet_name: '产品列表',
  238. sheet_values: this.tableData.data.map(item => ({
  239. '创建时间': Foundation.unixToDate(item.create_time),
  240. '项目号': item.order_no,
  241. '产品名称': item.name,
  242. '生产型号': item.code,
  243. '生产编码': item.no,
  244. '数量': item.qty,
  245. '销售备注': item.sales_remark,
  246. '要求发货日期': Foundation.unixToDate(item.ship_date_required),
  247. '技术': item.name,
  248. '硬件版本': item.hard_ver,
  249. '软件版本': item.soft_ver,
  250. '技术备注': item.tech_remark,
  251. '生产人': item.produce_name,
  252. '生产状态': item.produce_status,
  253. '已产数量': item.produced_qty
  254. }))
  255. }
  256. this.MixinExportJosnToExcel(json, '产品列表')
  257. },
  258. outSelect() {
  259. if (this.multipleSelection.length === 0) {
  260. this.$message.error('没有选中的项')
  261. return false
  262. }
  263. const json = {
  264. sheet_name: '产品列表',
  265. sheet_values: this.multipleSelection.map(item => ({
  266. '创建时间': Foundation.unixToDate(item.create_time),
  267. '项目号': item.order_no,
  268. '产品名称': item.name,
  269. '生产型号': item.code,
  270. '生产编码': item.no,
  271. '数量': item.qty,
  272. '销售备注': item.sales_remark,
  273. '要求发货日期': Foundation.unixToDate(item.ship_date_required),
  274. '技术': item.name,
  275. '硬件版本': item.hard_ver,
  276. '软件版本': item.soft_ver,
  277. '技术备注': item.tech_remark,
  278. '生产人': item.produce_name,
  279. '生产状态': item.produce_status,
  280. '已产数量': item.produced_qty
  281. }))
  282. }
  283. this.MixinExportJosnToExcel(json, '产品列表')
  284. },
  285. GET_GroupList() {
  286. this.loading = true
  287. API_orderItems.getPageGroupList(this.params).then(response => {
  288. this.loading = false
  289. this.tableData = response
  290. }).catch(() => (this.loading = false))
  291. },
  292. sousuo() {
  293. this.params.page_no = 1
  294. this.GET_List()
  295. },
  296. sousuo2() {
  297. this.params2.page_no = 1
  298. this.GET_List2()
  299. },
  300. handleDetail2(row) {
  301. this.myTitle = row.name
  302. this.params2.good_id = row.good_id
  303. this.GET_List2()
  304. this.drawerShow = true
  305. }
  306. }
  307. }
  308. </script>
  309. <style type="text/scss" lang="scss" scoped>
  310. /deep/ .el-table td:not(.is-left) {
  311. text-align: center;
  312. }
  313. .inner-toolbar {
  314. display: flex;
  315. width: 100%;
  316. justify-content: space-between;
  317. }
  318. .toolbar-search {
  319. margin-right: 10px;
  320. }
  321. .goods-info {
  322. display: flex;
  323. align-items: center;
  324. .goods-image {
  325. img {
  326. width: 80px;
  327. height: 80px;
  328. }
  329. }
  330. .goods-name-box {
  331. text-align: left;
  332. .goods-name {
  333. display: -webkit-box;
  334. -webkit-box-orient: vertical;
  335. -webkit-line-clamp: 2;
  336. overflow: hidden;
  337. a:hover {
  338. color: #f42424 !important;
  339. }
  340. }
  341. }
  342. }
  343. </style>