赫艾前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
11 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="mod-config yzz">
  3. <!-- 出入库记录(单头 + 明细合并显示) -->
  4. <div class="trans-section">
  5. <p class="section-title">出入库记录</p>
  6. <el-form :inline="true" label-position="top" style="margin-top: 0px">
  7. <el-form-item label="工厂编码">
  8. <el-input v-model="searchForm.site" style="width: 100px" clearable/>
  9. </el-form-item>
  10. <el-form-item label="出入库单号">
  11. <el-input v-model="searchForm.transNo" style="width: 160px" clearable/>
  12. </el-form-item>
  13. <el-form-item label="出入库类型">
  14. <el-select v-model="searchForm.transType" style="width: 160px" clearable placeholder="全部">
  15. <el-option label="全部" value=""/>
  16. <el-option
  17. v-for="item in transTypeOptions"
  18. :key="item"
  19. :label="item"
  20. :value="item"/>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="出入库方向">
  24. <el-select v-model="searchForm.direction" style="width: 100px" clearable placeholder="全部">
  25. <el-option label="全部" value=""/>
  26. <el-option label="入库" value="+"/>
  27. <el-option label="出库" value="-"/>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="经手人">
  31. <el-input v-model="searchForm.receiver" style="width: 120px" clearable/>
  32. </el-form-item>
  33. <el-form-item label="工具实例编码">
  34. <el-input v-model="searchForm.toolInstanceId" style="width: 160px" clearable/>
  35. </el-form-item>
  36. <el-form-item label="仓库编码">
  37. <el-input v-model="searchForm.wareHouseId" style="width: 120px" clearable/>
  38. </el-form-item>
  39. <el-form-item label="库位编码">
  40. <el-input v-model="searchForm.locationId" style="width: 120px" clearable/>
  41. </el-form-item>
  42. <el-form-item label="派工单号">
  43. <el-input v-model="searchForm.orderRef3" style="width: 140px" clearable/>
  44. </el-form-item>
  45. <el-form-item :label="'供应商'">
  46. <span slot="label" @click="getBaseList(73)"><a >供应商名称</a></span>
  47. <el-input v-model="searchForm.supplierName" style="width: 180px" clearable @input="onSupplierInput"></el-input>
  48. </el-form-item>
  49. <el-form-item label=" ">
  50. <el-button type="primary" @click="search()" :loading="dataListLoading">查询</el-button>
  51. <!-- 导出功能 -->
  52. <!--download-excel
  53. :fields="mergeFields()"
  54. type="xls"
  55. :name="exportName"
  56. :fetch="createExportData"
  57. worksheet="导出信息"
  58. class="el-button el-button--primary el-button--medium"
  59. style="margin-left: 8px;">
  60. 导出
  61. </download-excel-->
  62. </el-form-item>
  63. </el-form>
  64. <el-table
  65. :data="dataList"
  66. :height="tableHeight"
  67. border
  68. highlight-current-row
  69. v-loading="dataListLoading"
  70. style="width: 100%;">
  71. <el-table-column
  72. v-for="(item,index) in columnList"
  73. :key="index"
  74. :sortable="item.columnSortable"
  75. :prop="item.columnProp"
  76. header-align="center"
  77. :show-overflow-tooltip="item.showOverflowTooltip"
  78. :align="item.align"
  79. :fixed="item.fixed==''?false:item.fixed"
  80. :min-width="item.columnWidth"
  81. :label="item.columnLabel">
  82. <template slot-scope="scope">
  83. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <el-pagination
  88. @size-change="sizeChange"
  89. @current-change="currentChange"
  90. :current-page="pageIndex"
  91. :page-sizes="[20, 50, 100]"
  92. :page-size="pageSize"
  93. :total="total"
  94. layout="total, sizes, prev, pager, next, jumper">
  95. </el-pagination>
  96. </div>
  97. <!-- 基础列表选择弹窗(供应商 tagNo=73) -->
  98. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  99. </div>
  100. </template>
  101. <script>
  102. /**
  103. * 工具出入库记录查询页面
  104. * 出入库单头(tool_trans_header) + 出入库明细(tool_trans_detail) 合并为一个列表显示
  105. */
  106. import {
  107. searchToolTransMergePage,
  108. searchToolTransTypeList
  109. } from '@/api/production/tool.js'
  110. import Chooselist from '@/views/modules/common/Chooselist'
  111. /** 合并列表列(单头字段 + 明细字段) */
  112. const MERGE_COLUMN_SPECS = [
  113. { prop: 'site', label: '工厂编码', width: 70, align: 'center' },
  114. { prop: 'transNo', label: '出入库单号', width: 150, align: 'left', tooltip: true },
  115. { prop: 'transDate', label: '出入库日期', width: 110, align: 'center' },
  116. { prop: 'transType', label: '出入库类型', width: 130, align: 'left', tooltip: true },
  117. { prop: 'receiver', label: '经手人', width: 90, align: 'left' },
  118. { prop: 'status', label: '状态', width: 80, align: 'center' },
  119. { prop: 'direction', label: '出入库方向', width: 90, align: 'center' },
  120. { prop: 'toolInstanceId', label: '工具实例编码', width: 130, align: 'left', tooltip: true },
  121. { prop: 'itemNo', label: '行号', width: 70, align: 'center' },
  122. { prop: 'wareHouseId', label: '仓库编码', width: 90, align: 'left' },
  123. { prop: 'locationId', label: '库位编码', width: 90, align: 'left' },
  124. { prop: 'orderRef3', label: '派工单号', width: 110, align: 'left', tooltip: true },
  125. { prop: 'supplierName', label: '供应商', width: 140, align: 'left', tooltip: true },
  126. { prop: 'createdBy', label: '创建人', width: 90, align: 'left' },
  127. { prop: 'createdDate', label: '创建时间', width: 145, align: 'center' },
  128. { prop: 'remark', label: '备注', width: 180, align: 'left', tooltip: true }
  129. ]
  130. /** 列配置转为与 cancelSfdcForWareHouse 相同的字段结构 */
  131. function buildColumnList (specs, tableId, vm) {
  132. return specs.map(spec => ({
  133. tableId: tableId,
  134. tableName: vm.$route.meta.title,
  135. columnProp: spec.prop,
  136. columnLabel: spec.label,
  137. columnHidden: false,
  138. columnImage: false,
  139. columnSortable: false,
  140. columnWidth: spec.width,
  141. format: null,
  142. functionId: vm.$route.meta.menuId,
  143. sortLv: 0,
  144. status: true,
  145. fixed: '',
  146. serialNumber: null,
  147. columnType: null,
  148. align: spec.align || 'left',
  149. showOverflowTooltip: !!spec.tooltip,
  150. slotKey: ''
  151. }))
  152. }
  153. export default {
  154. name: 'toolInventoryLog',
  155. components: {
  156. Chooselist
  157. },
  158. data () {
  159. return {
  160. tableHeight: 400,
  161. dataListLoading: false,
  162. // 当前打开的基础列表 tagNo(回调分发用)
  163. tagNo: 0,
  164. // 出入库类型下拉选项
  165. transTypeOptions: [],
  166. // 合并列表查询条件
  167. searchForm: {
  168. site: '',
  169. transNo: '',
  170. transType: '',
  171. direction: '',
  172. receiver: '',
  173. toolInstanceId: '',
  174. wareHouseId: '',
  175. locationId: '',
  176. orderRef3: '',
  177. supplierId: '',
  178. supplierName: ''
  179. },
  180. dataList: [],
  181. pageIndex: 1,
  182. pageSize: 20,
  183. total: 0,
  184. exportName: '工具出入库记录' + this.getStrDate()
  185. }
  186. },
  187. computed: {
  188. columnList () {
  189. return buildColumnList(MERGE_COLUMN_SPECS, 'toolTransMergeList', this)
  190. }
  191. },
  192. mounted () {
  193. this.loadTransTypeOptions()
  194. this.$nextTick(() => {
  195. this.tableHeight = window.innerHeight - 300
  196. })
  197. },
  198. methods: {
  199. /** 加载出入库类型下拉 */
  200. loadTransTypeOptions () {
  201. searchToolTransTypeList({}).then(({ data }) => {
  202. if (data && data.code === 0) {
  203. this.transTypeOptions = data.list || []
  204. }
  205. }).catch(() => {
  206. this.transTypeOptions = []
  207. })
  208. },
  209. /** 查询出入库记录(单头 + 明细合并) */
  210. search () {
  211. this.dataListLoading = true
  212. const payload = {
  213. site: this.searchForm.site ? this.searchForm.site.trim() : undefined,
  214. transNo: this.searchForm.transNo ? this.searchForm.transNo.trim() : undefined,
  215. transType: this.searchForm.transType ? this.searchForm.transType.trim() : undefined,
  216. direction: this.searchForm.direction ? this.searchForm.direction : undefined,
  217. receiver: this.searchForm.receiver ? this.searchForm.receiver.trim() : undefined,
  218. toolInstanceId: this.searchForm.toolInstanceId ? this.searchForm.toolInstanceId.trim() : undefined,
  219. wareHouseId: this.searchForm.wareHouseId ? this.searchForm.wareHouseId.trim() : undefined,
  220. locationId: this.searchForm.locationId ? this.searchForm.locationId.trim() : undefined,
  221. orderRef3: this.searchForm.orderRef3 ? this.searchForm.orderRef3.trim() : undefined,
  222. supplierId: this.searchForm.supplierId ? this.searchForm.supplierId : (this.searchForm.supplierName ? this.searchForm.supplierName.trim() : undefined),
  223. page: this.pageIndex,
  224. limit: this.pageSize
  225. }
  226. searchToolTransMergePage(payload).then(({ data }) => {
  227. this.dataListLoading = false
  228. if (data && data.code === 0 && data.page) {
  229. this.dataList = data.page.list || []
  230. this.total = data.page.totalCount
  231. } else {
  232. this.dataList = []
  233. this.total = 0
  234. }
  235. }).catch(() => {
  236. this.dataListLoading = false
  237. this.$message.error('查询失败')
  238. })
  239. },
  240. sizeChange (val) {
  241. this.pageSize = val
  242. this.pageIndex = 1
  243. this.search()
  244. },
  245. currentChange (val) {
  246. this.pageIndex = val
  247. this.search()
  248. },
  249. /** 获取基础数据列表(供应商 tagNo=73) */
  250. getBaseList (val) {
  251. this.tagNo = val
  252. this.$nextTick(() => {
  253. let strVal = ''
  254. if (val === 73) {
  255. strVal = this.searchForm.supplierId
  256. }
  257. this.$refs.baseList.init(val, strVal)
  258. })
  259. },
  260. /** 列表方法的回调 */
  261. getBaseData (val) {
  262. if (this.tagNo === 73) {
  263. this.searchForm.supplierId = val.SupplierID || val.supplier_id || ''
  264. this.searchForm.supplierName = val.SupplierName || val.supplier_name || this.searchForm.supplierId
  265. }
  266. },
  267. /** 手动修改/清空供应商输入时,使已选 ID 失效(后端支持按输入内容模糊匹配编码或名称) */
  268. onSupplierInput () {
  269. this.searchForm.supplierId = ''
  270. },
  271. /** 动态导出列 */
  272. mergeFields () {
  273. return this.buildFields(this.columnList)
  274. },
  275. buildFields (columnList) {
  276. let json = '{'
  277. columnList.forEach((item, index) => {
  278. json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"' + (index === columnList.length - 1 ? '' : ',')
  279. })
  280. json += '}'
  281. return eval('(' + json + ')')
  282. },
  283. /** 导出当前页数据 */
  284. createExportData () {
  285. return this.dataList
  286. },
  287. /** 导出文件名时间戳 */
  288. getStrDate () {
  289. const dd = new Date()
  290. const Y = dd.getFullYear()
  291. const M = (dd.getMonth() + 1) < 10 ? '0' + (dd.getMonth() + 1) : (dd.getMonth() + 1)
  292. const D = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()
  293. const H = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  294. const MM = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  295. const S = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  296. return Y + '' + M + D + H + MM + S
  297. }
  298. }
  299. }
  300. </script>
  301. <style scoped>
  302. .trans-section {
  303. border: 1px solid #e4e7ed;
  304. padding: 10px 10px 6px 10px;
  305. }
  306. .section-title {
  307. margin: 0 0 6px 0;
  308. font-size: 16px;
  309. font-weight: bold;
  310. }
  311. </style>