supplier-capacity.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <!-- 供应商产能维护 -->
  3. <div id="preBookList">
  4. <!-- 查询区域 -->
  5. <a-card :bordered="false">
  6. <div class="table-page-search-wrapper">
  7. <a-form layout="inline" @keyup.enter.native="searchQuery">
  8. <a-row :gutter="24">
  9. <a-col :md="6" :sm="8">
  10. <a-form-item label="供应商">
  11. <a-input placeholder="请输入供应商" v-model="queryParam.supplier"></a-input>
  12. </a-form-item>
  13. </a-col>
  14. <a-col :md="6" :sm="8">
  15. <a-form-item label="供应商分类">
  16. <a-select v-model="queryParam.cvenCodeType" show-search allowClear :filterOption="filterOption" >
  17. <a-select-option
  18. v-for="(item,index) in SupplierTypeOption"
  19. :key="index"
  20. :value="item.cvenCodeType">
  21. {{item.cvenCodeType}}
  22. </a-select-option>
  23. </a-select>
  24. <!-- <a-input placeholder="请输入" v-model="queryParam.cvenCodeType"></a-input> -->
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="8">
  28. <a-form-item label="供应商状态">
  29. <a-select v-model="queryParam.supplierState" placeholder="请选择发货情况" >
  30. <a-select-option value="">请选择</a-select-option>
  31. <a-select-option value="正常">正常</a-select-option>
  32. <a-select-option value="关闭">关闭</a-select-option>
  33. </a-select>
  34. <!-- <a-input placeholder="请输入" v-model="queryParam.supplierState"></a-input> -->
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="8">
  38. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  39. <a-button type="primary" @click="getSupplierList" icon="search">查询</a-button>
  40. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  41. <a @click="handleToggleSearch" style="margin-left: 8px">
  42. {{ toggleSearchStatus ? '收起' : '展开' }}
  43. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  44. </a>
  45. </span>
  46. </a-col>
  47. </a-row>
  48. </a-form>
  49. </div>
  50. </a-card>
  51. <!-- 操作按钮区域 新增-->
  52. <a-card :bordered="false" style="marginTop:10px;">
  53. <div class="table-operator">
  54. <a-button type="primary" icon="plus" @click="addLine">增行</a-button>
  55. <a-button type="primary" icon="plus" @click="editLine">修改</a-button>
  56. <a-button type="primary" icon="plus" @click="delectLLine">删除</a-button>
  57. <a-button type="primary" icon="plus" @click="saveLine">保存</a-button>
  58. <a-button type="primary" icon="plus" @click="cancelLine">取消</a-button>
  59. <!-- <a-button type="primary" icon="plus" @click="subitLine">提交</a-button>
  60. <a-button type="primary" icon="plus" @click="cancelSubitLine">取消提交</a-button> -->
  61. </div>
  62. <!-- 子表 -->
  63. <a-table
  64. bordered
  65. v-if="suplierListData"
  66. :row-key="record => record.id"
  67. :columns="suplierListColumns"
  68. :data-source="suplierListData"
  69. :loading="loading"
  70. :height="500"
  71. :pagination="pagination"
  72. @change="handleTableChange"
  73. :rowSelection="{ selectedRowKeys: selectedRowKeys,onChange: onSelectChange }"
  74. :scroll="{ x: 1200,}"
  75. >
  76. <!-- 供应商编码 -->
  77. <template slot="supplierCode" slot-scope="text, record, index" >
  78. <a-form-model-item prop="supplierCode" :rules="rules.supplierCode" v-if="record.status == '0'">
  79. <a-input placeholder="根据供应商名称自动带出" v-model="record.supplierCode" readOnly></a-input>
  80. </a-form-model-item>
  81. <a-form-model-item prop="supplierCode" :rules="rules.supplierCode" v-if="record.status == '1'">
  82. <span>{{record.supplierCode}}</span>
  83. </a-form-model-item>
  84. </template>
  85. <!-- 供应商名称 -->
  86. <template slot="supplier" slot-scope="text, record" >
  87. <a-form-model-item prop="supplier" :rules="rules.supplier" v-if="record.status == '0'">
  88. <a-select v-model="record.supplier" show-search :filterOption="filterOption" @change="changeSuplier($event,record)" style="width: 200px" >
  89. <a-select-option
  90. v-for="(item,index) in option"
  91. :key="index"
  92. :value="item.supplier">
  93. {{item.supplier}}
  94. </a-select-option>
  95. </a-select>
  96. </a-form-model-item>
  97. <a-form-model-item prop="supplier" :rules="rules.supplier" v-if="record.status == '1'">
  98. <span>{{record.supplier}}</span>
  99. </a-form-model-item>
  100. </template>
  101. <!-- 供应商分类 -->
  102. <template slot="cvenCodeType" slot-scope="text, record, index" >
  103. <a-form-model-item prop="cvenCodeType" :rules="rules.cvenCodeType" v-if="record.status == '0'">
  104. <a-select v-model="record.cvenCodeType" show-search :filterOption="filterOption" style="width: 120px" >
  105. <a-select-option
  106. v-for="(item,index) in SupplierTypeOption"
  107. :key="index"
  108. :value="item.cvenCodeType">
  109. {{item.cvenCodeType}}
  110. </a-select-option>
  111. </a-select>
  112. <!-- <a-input style="width:100%" type="text" v-model="record.cvenCodeType" /> -->
  113. </a-form-model-item>
  114. <a-form-model-item prop="cvenCodeType" :rules="rules.cvenCodeType" v-if="record.status == '1'">
  115. <span>{{record.cvenCodeType}}</span>
  116. </a-form-model-item>
  117. </template>
  118. <!-- 产能额度(月) -->
  119. <template slot="capacityQuota" slot-scope="text, record, index" >
  120. <a-form-model-item prop="capacityQuota" :rules="rules.capacityQuota" v-if="record.status == '0'">
  121. <a-input style="width:100%" type="text" v-model="record.capacityQuota" />
  122. </a-form-model-item>
  123. <a-form-model-item prop="capacityQuota" :rules="rules.capacityQuota" v-if="record.status == '1'">
  124. <span>{{record.capacityQuota}}</span>
  125. </a-form-model-item>
  126. </template>
  127. <!-- 工时(月) -->
  128. <template slot="workingHours" slot-scope="text, record, index" >
  129. <a-form-model-item prop="workingHours" :rules="rules.workingHours" v-if="record.status == '0'">
  130. <a-input style="width:100%" type="text" v-model="record.workingHours" />
  131. </a-form-model-item>
  132. <a-form-model-item prop="workingHours" :rules="rules.workingHours" v-if="record.status == '1'">
  133. <span>{{record.workingHours}}</span>
  134. </a-form-model-item>
  135. </template>
  136. <!-- 产能额度上浮区间 -->
  137. <template slot="capacitySection" slot-scope="text, record, index" >
  138. <a-form-model-item prop="capacitySection" :rules="rules.capacitySection" v-if="record.status == '0'">
  139. <a-input style="width:100%" type="text" v-model="record.capacitySection" @change="changeCapacitySection(record)">
  140. <i slot="suffix">%</i>
  141. </a-input>
  142. </a-form-model-item>
  143. <a-form-model-item prop="capacitySection" :rules="rules.capacitySection" v-if="record.status == '1'">
  144. <span>{{record.capacitySection+'%'}}</span>
  145. </a-form-model-item>
  146. </template>
  147. <!-- 供应商状态 -->
  148. <template slot="supplierState" slot-scope="text, record, index" >
  149. <a-form-model-item prop="supplierState" :rules="rules.supplierState" v-if="record.status == '0'">
  150. <a-select v-model="record.supplierState" style="width: 120px" placeholder="请选择" >
  151. <a-select-option value="正常">正常</a-select-option>
  152. <a-select-option value="关闭">关闭</a-select-option>
  153. </a-select>
  154. </a-form-model-item>
  155. <a-form-model-item prop="supplierState" :rules="rules.supplierState" v-if="record.status == '1'">
  156. <span>{{record.supplierState}}</span>
  157. </a-form-model-item>
  158. </template>
  159. <!-- 备注 -->
  160. <template slot="remarks" slot-scope="text, record, index" >
  161. <a-form-model-item prop="remarks" :rules="rules.remarks" v-if="record.status == '0'">
  162. <a-input style="width:100%" type="text" v-model="record.remarks" />
  163. </a-form-model-item>
  164. <a-form-model-item prop="remarks" :rules="rules.remarks" v-if="record.status == '1'">
  165. <span>{{record.remarks}}</span>
  166. </a-form-model-item>
  167. </template>
  168. </a-table>
  169. </a-card>
  170. </div>
  171. </template>
  172. <script>
  173. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  174. import JEllipsis from '@/components/jeecg/JEllipsis'
  175. import moment from 'moment'
  176. import { supplierList,addSupplierList,editSupplierList,deleteSupplierList ,option,getSupplierTypeOption} from '@api/reportForms/supplier-capacity'
  177. export default {
  178. name: 'PreBookList', // 预托书列表
  179. mixins: [JeecgListMixin],
  180. components: { JEllipsis, moment},
  181. data() {
  182. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  183. return {
  184. // 表头
  185. suplierListColumns: [
  186. {
  187. title: '供应商名称',
  188. dataIndex: 'supplier',
  189. width: 150,
  190. className: 'replacecolor' ,
  191. scopedSlots: { customRender: 'supplier' },
  192. },
  193. {
  194. title: '产能额度(月)',
  195. dataIndex: 'capacityQuota',
  196. width: 120,
  197. className: 'replacecolor',
  198. scopedSlots: { customRender: 'capacityQuota' },
  199. },
  200. {
  201. title: '工时(时/月)',
  202. dataIndex: 'workingHours',
  203. width: 100,
  204. className: 'replacecolor',
  205. scopedSlots: { customRender: 'workingHours' },
  206. },
  207. {
  208. title: '上浮区间%',
  209. dataIndex: 'capacitySection',
  210. width: 80,
  211. className: 'replacecolor',
  212. scopedSlots: { customRender: 'capacitySection' },
  213. },
  214. {
  215. title: '供应商编码',
  216. width: 100,
  217. dataIndex: 'supplierCode',
  218. className: 'replacecolor',
  219. scopedSlots: { customRender: 'supplierCode' },
  220. },
  221. {
  222. title: '供应商分类',
  223. dataIndex: 'cvenCodeType',
  224. width: 100,
  225. scopedSlots: { customRender: 'cvenCodeType' },
  226. className: 'replacecolor' ,
  227. },
  228. {
  229. title: '供应商状态',
  230. dataIndex: 'supplierState',
  231. width: 100,
  232. className: 'replacecolor' ,
  233. scopedSlots: { customRender: 'supplierState' },
  234. },
  235. {
  236. title: '备注',
  237. dataIndex: 'remarks',
  238. width: 140,
  239. className: 'replacecolor' ,
  240. // ellipsis: true,
  241. scopedSlots: { customRender: 'remarks' },
  242. },
  243. ],
  244. option:[],
  245. suplierListData: [
  246. ],
  247. selectedRowKeys:[],
  248. selectedRows:[],
  249. SupplierTypeOption:[],
  250. loading: false, // 表格加载
  251. // 查询条件
  252. queryParam: {
  253. cvenCodeType:'成衣厂',
  254. supplierState:'正常'
  255. },
  256. pagination: {
  257. // total: '',
  258. // current: 0,
  259. // pageSize: 0
  260. },
  261. defaultMode:'add'
  262. }
  263. },
  264. async created() {
  265. await this.getOption()
  266. this.getSupplierList()
  267. },
  268. computed: {},
  269. mounted() {},
  270. methods: {
  271. getOption(){
  272. option().then(res => {
  273. this.option = res
  274. })
  275. getSupplierTypeOption().then(res => {
  276. this.SupplierTypeOption = res
  277. })
  278. },
  279. // 分页查询
  280. getSupplierList(){
  281. this.$nextTick(() => {
  282. // this.queryParam.pageSize = 20
  283. supplierList(this.queryParam).then(res => {
  284. if (res.success) {
  285. this.suplierListData = res.result.records;
  286. this.loading = false
  287. this.pagination = {
  288. total: res.result.total,
  289. current: res.result.current,
  290. pageSize: res.result.size
  291. }
  292. if(this.suplierListData.length !== 0){
  293. this.suplierListData.map(item=>{
  294. item.status = '1'
  295. })
  296. }
  297. }else{
  298. this.$message.error(res.message);
  299. }
  300. })
  301. })
  302. },
  303. //重置
  304. searchReset(){
  305. this.queryParam = {
  306. cvenCodeType:'成衣厂',
  307. supplierState:'正常'
  308. }
  309. this.getSupplierList()
  310. },
  311. //报关品名下拉框模糊搜索
  312. filterOption(input, option) {
  313. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  314. },
  315. addLine(){
  316. var operation = 0
  317. this.suplierListData.map(item=>{
  318. if(item.status == 0){
  319. operation +=1
  320. }
  321. })
  322. if(operation == 0){
  323. var line ={
  324. supplierCode:'',
  325. supplier:'',
  326. capacityQuota:'',
  327. workingHours:'',
  328. cvenCodeType:'成衣厂',
  329. supplierState:'正常',
  330. remarks:'',
  331. status : '0'
  332. }
  333. this.suplierListData.unshift(line)
  334. }else{
  335. this.$message.error('当前有操作未完成');
  336. }
  337. },
  338. editLine(){
  339. var operation = 0
  340. this.suplierListData.map(item=>{
  341. if(item.status == 0){
  342. operation +=1
  343. }
  344. })
  345. if(this.selectedRowKeys.length == '0'){
  346. this.$message.error('请勾选需要修改的数据');
  347. }else if(this.selectedRowKeys.length > 1){
  348. this.$message.error('一次只允许修改一行数据');
  349. }else if(operation !== 0){
  350. this.$message.error('当前有操作未完成');
  351. }else{
  352. this.suplierListData.map(item =>{
  353. if(item.id == this.selectedRows[0].id){
  354. item.status = '0'
  355. }
  356. })
  357. this.defaultMode = 'edit'
  358. this.$forceUpdate()
  359. }
  360. },
  361. changeSuplier(val,record){
  362. this.option.map(item =>{
  363. if(item.supplier == record.supplier) {
  364. record.supplierCode = item.supplier_code
  365. record.cvenCodeType = item.cvenCodeType
  366. }
  367. })
  368. },
  369. changeCapacitySection(record){
  370. if(record.capacitySection < 0 || record.capacitySection>100){
  371. this.$message.destroy();
  372. this.$message.error('产能额度上浮区间必须是大于0小于100',1);
  373. }
  374. },
  375. delectLLine(){
  376. if(this.selectedRowKeys.length == '0'){
  377. this.$message.error('请勾选需要删除的数据');
  378. }else if(this.selectedRowKeys.length > 1){
  379. this.$message.error('一次只允许删除一行数据');
  380. }else{
  381. var objNew = this.selectedRows[0]
  382. objNew.state = '-1'
  383. editSupplierList(objNew).then(res => {
  384. if (res.success) {
  385. this.$message.success('删除成功');
  386. this.getSupplierList()
  387. this.selectedRowKeys = []
  388. this.selectedRows = []
  389. }else{
  390. this.$message.error(res.message);
  391. }
  392. })
  393. }
  394. },
  395. saveLine(){
  396. var newObj = {}
  397. //获取修改的数据
  398. this.suplierListData.map(item =>{
  399. if(item.status == 0){
  400. newObj = item
  401. }
  402. })
  403. //校验产能额度上浮区间
  404. if(newObj.capacitySection == '' || !newObj.capacitySection){
  405. this.$message.error('产能额度上浮区间为必填',1);
  406. }else if(newObj.capacitySection < 0 || newObj.capacitySection>100){
  407. this.$message.error('产能额度上浮区间必须是大于0小于100',1);
  408. }else{
  409. if(this.defaultMode == 'add'){
  410. newObj.state = '1'
  411. addSupplierList(newObj).then(res => {
  412. if (res.success) {
  413. this.$message.success('新增成功');
  414. this.getSupplierList()
  415. }else{
  416. this.$message.error(res.message);
  417. }
  418. })
  419. }else {
  420. editSupplierList(newObj).then(res => {
  421. if (res.success) {
  422. this.$message.success('修改成功');
  423. this.getSupplierList()
  424. this.selectedRowKeys = []
  425. this.selectedRows = []
  426. }else{
  427. this.$message.error(res.message);
  428. }
  429. //清空勾选恢复默认
  430. this.selectedRowKeys = []
  431. this.selectedRows = []
  432. this.defaultMode = 'add'
  433. })
  434. }
  435. }
  436. },
  437. cancelLine(){
  438. this.getSupplierList()
  439. this.defaultMode ='add'
  440. this.selectedRowKeys=[]
  441. this.selectedRows = []
  442. },
  443. subitLine(){
  444. if(this.selectedRowKeys.length ==0){
  445. this.$message.error('请勾选需要提交的数据');
  446. }else if(this.selectedRowKeys.length > 1){
  447. this.$message.error('一次只可提交一行数据');
  448. }else if(this.selectedRows[0].state == '1'){
  449. this.$message.error('不可重复提交');
  450. }else {
  451. var objNew = this.selectedRows[0]
  452. objNew.state = '1'
  453. editSupplierList(objNew).then(res => {
  454. if (res.success) {
  455. this.$message.success('提交成功');
  456. this.getSupplierList()
  457. this.selectedRowKeys = []
  458. this.selectedRows = []
  459. }else{
  460. this.$message.error(res.message);
  461. }
  462. })
  463. }
  464. },
  465. cancelSubitLine(){
  466. if(this.selectedRowKeys.length ==0){
  467. this.$message.error('请勾选需要取消提交的数据');
  468. }else if(this.selectedRowKeys.length > 1){
  469. this.$message.error('一次只可取消一行');
  470. }else if(this.selectedRows[0].state == '0'){
  471. this.$message.error('选择的数据未提交');
  472. }else{
  473. var objNew = this.selectedRows[0]
  474. objNew.state = '0'
  475. editSupplierList(objNew).then(res => {
  476. if (res.success) {
  477. this.$message.success('取消提交成功');
  478. this.getSupplierList()
  479. this.selectedRowKeys = []
  480. this.selectedRows = []
  481. }else{
  482. this.$message.error(res.message);
  483. }
  484. })
  485. }
  486. },
  487. // 选中行
  488. onSelectChange(keys, rows) {
  489. this.selectedRowKeys = keys
  490. this.selectedRows = rows
  491. },
  492. // 分页、排序、筛选变化时触发
  493. handleTableChange(pagination, filters, sorter) {
  494. // console.log('当前页信息>>>>',pagination)
  495. this.queryParam.pageNo = pagination.current
  496. this.getSupplierList()
  497. }
  498. }
  499. }
  500. </script>
  501. <style lang="less" scoped>
  502. @import '~@assets/less/common.less';
  503. @import '~@assets/less/overwriter.less';
  504. /deep/ .ant-table-thead > tr > th {
  505. text-align: center;
  506. // font-weight: 700;
  507. }
  508. /deep/ .ant-table-tbody {
  509. text-align: center;
  510. }
  511. /deep/ .ant-form-item {
  512. margin-bottom: 0;
  513. }
  514. /deep/.ant-table-tbody .ant-table-row td{
  515. padding-top: 0px;
  516. padding-bottom: 0px;
  517. }
  518. </style>