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.

354 lines
11 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. <template>
  2. <div class="customer-css" >
  3. <!-- 查询时间和产品 -->
  4. <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;" >
  5. <el-row>
  6. <el-col :span="24" style="">
  7. <el-form-item :label="'Material Family No:'">
  8. <el-input v-model="searchData.materialFamilyNo" style="width: 130px"></el-input>
  9. </el-form-item>
  10. <el-form-item :label="'Material Family Desc:'">
  11. <el-input v-model="searchData.materialFamilyDesc" style="width: 130px"></el-input>
  12. </el-form-item>
  13. <el-form-item :label="' '" >
  14. <el-button class="customer-bun-min" type="primary" @click="getMainData" style="">Query</el-button>
  15. <el-button class="customer-bun-min" type="primary" @click="openModelData" style="">New Family</el-button>
  16. <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'Export'}}</el-button>
  17. </el-form-item>
  18. </el-col>
  19. </el-row>
  20. </el-form>
  21. <el-table
  22. :height="height"
  23. :data="mainDataList"
  24. border
  25. ref="mainTable"
  26. highlight-current-row
  27. @row-click="changeData"
  28. v-loading="dataListLoading"
  29. style="margin-top: 0px; width: 100%;">
  30. <el-table-column
  31. fixed="right"
  32. header-align="center"
  33. align="center"
  34. width="220"
  35. :label="'Actions'">
  36. <template slot-scope="scope">
  37. <a class="customer-a" @click="openUpModel(scope.row)">Edit |</a>
  38. <a class="customer-a" @click="deleteFamily(scope.row)">Delete</a>
  39. </template>
  40. </el-table-column>
  41. <el-table-column
  42. v-for="(item,index) in columnArray1" :key="index"
  43. :sortable="item.columnSortable"
  44. :prop="item.columnProp"
  45. :header-align="item.headerAlign"
  46. :show-overflow-tooltip="item.showOverflowTooltip"
  47. :align="item.align"
  48. :fixed="item.fixed==''?false:item.fixed"
  49. :min-width="item.columnWidth"
  50. :label="item.columnLabel">
  51. <template slot-scope="scope">
  52. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  53. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  54. style="width: 100px; height: 80px"/></span>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <el-dialog title="Material Family" :close-on-click-modal="false" v-drag :visible.sync="addModelFlag" width="400px">
  59. <el-form label-position="top" style="margin-top: -5px;">
  60. <el-row :gutter="20">
  61. <el-col :span="12">
  62. <el-form-item :label="'Material Family No'" >
  63. <el-input v-model="addModelData.materialFamilyNo" :disabled="addModelData.flag===1" ></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="12">
  67. <el-form-item :label="'Material Family Desc'" >
  68. <el-input v-model="addModelData.materialFamilyDesc" ></el-input>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. </el-form>
  73. <el-footer style="height:40px;margin-top: 10px;text-align:center">
  74. <el-button type="primary" @click="submitData()">Submit</el-button>
  75. <el-button type="primary" @click="addModelFlag=false">Cancel & Close</el-button>
  76. </el-footer>
  77. </el-dialog>
  78. <el-tabs v-model="activeName" style="margin-top: 0px; width: 99%;" @tab-click="tabClick" class="customer-tab" type="border-card">
  79. <el-tab-pane label="Approved Vendor List" name="vendorList" style="">
  80. <vendorList ref="vendorList"></vendorList>
  81. </el-tab-pane>
  82. <!-- <el-tab-pane label="Share" name="share" style="">
  83. <share ref="share"></share>
  84. </el-tab-pane> -->
  85. </el-tabs>
  86. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  87. </div>
  88. </template>
  89. <script>
  90. /*组件*/
  91. import {
  92. searchMaterialFamilyData,
  93. } from '@/api/srm/srmSupplier.js'
  94. import excel from "@/utils/excel-util.js";
  95. import Chooselist from '@/views/modules/common/Chooselist_eam'
  96. import vendorList from './com_supplierShare_supplierList'
  97. import share from './com_supplierShare_share'
  98. import {deleteMaterialFamily, saveOrUpdateFamily} from '../../../api/srm/srmSupplier'
  99. export default {
  100. data() {
  101. return {
  102. functionId: this.$route.meta.menuId,
  103. height: 200,
  104. currentRow: {},
  105. searchData:{
  106. materialFamilyNo:'',
  107. materialFamilyDesc:'',
  108. delFlag:'N',
  109. site:this.$store.state.user.site,
  110. },
  111. addModelData:{
  112. flag:'',
  113. site:this.$store.state.user.site,
  114. materialFamilyNo:'',
  115. materialFamilyDesc:'',
  116. delFlag:'N',
  117. },
  118. tagNo:'',
  119. mainDataList:[],
  120. dataListLoading: false,
  121. activeName: 'vendorList',
  122. columnArray1: [
  123. {
  124. userId: this.$store.state.user.name,
  125. functionId: this.functionId,
  126. serialNumber: '811031Table1MaterialFamilyNo',
  127. tableId: "811031Table1",
  128. tableName: "物料分类信息",
  129. columnProp: "materialFamilyNo",
  130. headerAlign: "center",
  131. align: "left",
  132. columnLabel: "Material Family No",
  133. columnWidth: '100',
  134. columnHidden: false,
  135. columnImage: false,
  136. columnSortable: false,
  137. sortLv: 0,
  138. status: true,
  139. fixed: false
  140. },
  141. {
  142. userId: this.$store.state.user.name,
  143. functionId: this.functionId,
  144. serialNumber: '811031Table1MaterialFamilyDesc',
  145. tableId: "811031Table1",
  146. tableName: "物料分类信息",
  147. columnProp: "materialFamilyDesc",
  148. headerAlign: "center",
  149. align: "left",
  150. columnLabel: "Material Family Desc",
  151. columnWidth: '200',
  152. columnHidden: false,
  153. columnImage: false,
  154. columnSortable: false,
  155. sortLv: 0,
  156. status: true,
  157. fixed: false
  158. },
  159. ],
  160. addModelFlag:false,
  161. exportName: '物料分类信息'+this.dayjs().format('YYYYMMDDHHmmss'),
  162. }
  163. },
  164. /*组件*/
  165. components: {
  166. Chooselist,
  167. share,
  168. vendorList,
  169. },
  170. mounted() {
  171. this.$nextTick(() => {
  172. this.height = ( window.innerHeight - 210)/2;
  173. })
  174. },
  175. watch: {
  176. addModelData: {
  177. deep: true,
  178. handler: function (newV, oldV) {
  179. this.addModelData.materialFamilyNo = this.addModelData.materialFamilyNo.toUpperCase()
  180. }
  181. },
  182. searchData: {
  183. deep: true,
  184. handler: function (newV, oldV) {
  185. this.searchData.materialFamilyNo = this.searchData.materialFamilyNo.toUpperCase()
  186. }
  187. },
  188. },
  189. methods: {
  190. getBaseList(val, type) {
  191. this.tagNo = val
  192. this.$nextTick(() => {
  193. let strVal = ''
  194. if (val === 1100) {
  195. strVal = this.searchData.supplierNo
  196. }
  197. this.$refs.baseList.init(val, strVal)
  198. })
  199. },
  200. /* 列表方法的回调 */
  201. getBaseData(val) {
  202. if (this.tagNo === 1100) {
  203. this.searchData.supplierNo = val.supplier_no
  204. }
  205. },
  206. getMainData(){
  207. this.searchData.limit = this.pageSize
  208. this.searchData.page = this.pageIndex
  209. searchMaterialFamilyData(this.searchData).then(({data}) => {
  210. if (data.code === 0) {
  211. this.mainDataList = data.rows
  212. //判断是否全部存在数据
  213. if (this.mainDataList.length > 0) {
  214. //设置选中行
  215. this.$refs.mainTable.setCurrentRow(this.mainDataList[0])
  216. this.changeData(this.mainDataList[0])
  217. }else {
  218. this.changeData(null)
  219. }
  220. }
  221. this.dataListLoading = false
  222. })
  223. },
  224. tabClick(tab, event){
  225. this.refreshCurrentTabTable()
  226. },
  227. changeData(row){
  228. this.currentRow=JSON.parse(JSON.stringify(row))
  229. this.refreshCurrentTabTable ();
  230. },
  231. refreshCurrentTabTable(){
  232. if(this.currentRow===''||this.currentRow===null){
  233. this.currentRow={site:'',supplierNo:''}
  234. }
  235. // if(this.activeName==='share'){
  236. // this.refreshShareTable();
  237. // }
  238. if(this.activeName==='vendorList'){
  239. this.refreshVendorListTable();
  240. }
  241. },
  242. async exportExcel() {
  243. excel.exportTable({
  244. url: "/srmSupplierShare/searchMaterialFamilyData",
  245. columnMapping: this.columnArray1,//可以直接用table,不需要的列就剔除
  246. mergeSetting: [],//需要合并的列
  247. params: this.searchData,
  248. fileName: this.exportName+".xlsx",
  249. rowFetcher: res => res.data,
  250. columnFormatter: [],
  251. dropColumns: [],//需要剔除的列,例如dropColumns: ["netWeight"],即剔除净重列
  252. });
  253. },
  254. refreshVendorListTable(){
  255. let inData={
  256. site: this.currentRow.site,
  257. materialFamilyNo: this.currentRow.materialFamilyNo,
  258. materialFamilyDesc: this.currentRow.materialFamilyDesc,
  259. height:Number(this.height)
  260. }
  261. this.$refs.vendorList.init(inData)
  262. },
  263. refreshShareTable(){
  264. let inData={
  265. site: this.currentRow.site,
  266. materialFamilyNo: this.currentRow.materialFamilyNo,
  267. materialFamilyDesc: this.currentRow.materialFamilyDesc,
  268. height:Number(this.height)-30
  269. }
  270. this.$refs.share.init(inData)
  271. },
  272. openModelData(){
  273. this.addModelData={
  274. flag: 0,
  275. site: this.$store.state.user.site,
  276. materialFamilyNo: '',
  277. materialFamilyDesc: '',
  278. delFlag: 'N',
  279. }
  280. this.addModelFlag=true;
  281. },
  282. openUpModel(row){
  283. this.addModelData={
  284. flag: 1,
  285. site: row.site,
  286. materialFamilyNo: row.materialFamilyNo,
  287. materialFamilyDesc: row.materialFamilyDesc,
  288. delFlag: row.delFlag,
  289. }
  290. this.addModelFlag=true;
  291. },
  292. submitData(){
  293. saveOrUpdateFamily( this.addModelData).then(({data})=>{
  294. if (data && data.code === 0){
  295. this.$message.success(data.msg);
  296. this.getMainData();
  297. this.addModelFlag=false
  298. }else {
  299. this.$message.warning(data.msg);
  300. }
  301. }).catch((error)=>{
  302. this.$message.error(error);
  303. })
  304. },
  305. deleteFamily(row){
  306. this.$confirm('The data will be permanently deleted. Do you wish to proceed?', 'Prompt', {
  307. confirmButtonText: 'Confirm',
  308. cancelButtonText: 'Cancel',
  309. type: 'warning'
  310. }).then(() => {
  311. deleteMaterialFamily( row).then(({data})=>{
  312. if (data && data.code === 0){
  313. this.$message.success(data.msg);
  314. this.getMainData();
  315. this.addModelFlag=false
  316. }else {
  317. this.$message.warning(data.msg);
  318. }
  319. }).catch((error)=>{
  320. this.$message.error(error);
  321. })
  322. })
  323. },
  324. },
  325. created() {
  326. //查询报表的类型
  327. this.getMainData();
  328. },
  329. }
  330. </script>
  331. <!--当前页面的标签样式-->
  332. <style scoped lang="scss">
  333. /deep/ .customer-tab .el-tabs__content {
  334. padding: 5px !important;
  335. }
  336. </style>