supplier-capacity.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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 :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. },
  255. pagination: {
  256. // total: '',
  257. // current: 0,
  258. // pageSize: 0
  259. },
  260. defaultMode:'add'
  261. }
  262. },
  263. async created() {
  264. await this.getOption()
  265. this.getSupplierList()
  266. },
  267. computed: {},
  268. mounted() {},
  269. methods: {
  270. getOption(){
  271. option().then(res => {
  272. this.option = res
  273. })
  274. getSupplierTypeOption().then(res => {
  275. this.SupplierTypeOption = res
  276. })
  277. },
  278. // 分页查询
  279. getSupplierList(){
  280. this.$nextTick(() => {
  281. // this.queryParam.pageSize = 20
  282. supplierList(this.queryParam).then(res => {
  283. if (res.success) {
  284. this.suplierListData = res.result;
  285. this.loading = false
  286. this.pagination = {
  287. total: res.result.total,
  288. current: res.result.current,
  289. pageSize: res.result.size
  290. }
  291. if(this.suplierListData.length !== 0){
  292. this.suplierListData.map(item=>{
  293. item.status = '1'
  294. })
  295. }
  296. }else{
  297. this.$message.error(res.message);
  298. }
  299. })
  300. })
  301. },
  302. //重置
  303. searchReset(){
  304. this.queryParam = {
  305. cvenCodeType:'成衣厂'
  306. }
  307. this.getSupplierList()
  308. },
  309. //报关品名下拉框模糊搜索
  310. filterOption(input, option) {
  311. return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  312. },
  313. addLine(){
  314. var operation = 0
  315. this.suplierListData.map(item=>{
  316. if(item.status == 0){
  317. operation +=1
  318. }
  319. })
  320. if(operation == 0){
  321. var line ={
  322. supplierCode:'',
  323. supplier:'',
  324. capacityQuota:'',
  325. workingHours:'',
  326. cvenCodeType:'成衣厂',
  327. supplierState:'',
  328. remarks:'',
  329. status : '0'
  330. }
  331. this.suplierListData.unshift(line)
  332. }else{
  333. this.$message.error('当前有操作未完成');
  334. }
  335. },
  336. editLine(){
  337. var operation = 0
  338. this.suplierListData.map(item=>{
  339. if(item.status == 0){
  340. operation +=1
  341. }
  342. })
  343. if(this.selectedRowKeys.length == '0'){
  344. this.$message.error('请勾选需要修改的数据');
  345. }else if(this.selectedRowKeys.length > 1){
  346. this.$message.error('一次只允许修改一行数据');
  347. }else if(operation !== 0){
  348. this.$message.error('当前有操作未完成');
  349. }else{
  350. this.suplierListData.map(item =>{
  351. if(item.id == this.selectedRows[0].id){
  352. item.status = '0'
  353. }
  354. })
  355. this.defaultMode = 'edit'
  356. this.$forceUpdate()
  357. }
  358. },
  359. changeSuplier(val,record){
  360. this.option.map(item =>{
  361. if(item.supplier == record.supplier) {
  362. record.supplierCode = item.supplier_code
  363. record.cvenCodeType = item.cvenCodeType
  364. }
  365. })
  366. },
  367. changeCapacitySection(record){
  368. if(record.capacitySection < 0 || record.capacitySection>100){
  369. this.$message.destroy();
  370. this.$message.error('产能额度上浮区间必须是大于0小于100',1);
  371. }
  372. },
  373. delectLLine(){
  374. if(this.selectedRowKeys.length == '0'){
  375. this.$message.error('请勾选需要删除的数据');
  376. }else if(this.selectedRowKeys.length > 1){
  377. this.$message.error('一次只允许删除一行数据');
  378. }else{
  379. var objNew = this.selectedRows[0]
  380. objNew.state = '-1'
  381. editSupplierList(objNew).then(res => {
  382. if (res.success) {
  383. this.$message.success('删除成功');
  384. this.getSupplierList()
  385. this.selectedRowKeys = []
  386. this.selectedRows = []
  387. }else{
  388. this.$message.error(res.message);
  389. }
  390. })
  391. }
  392. },
  393. saveLine(){
  394. var newObj = {}
  395. //获取修改的数据
  396. this.suplierListData.map(item =>{
  397. if(item.status == 0){
  398. newObj = item
  399. }
  400. })
  401. //校验产能额度上浮区间
  402. if(newObj.capacitySection == '' || !newObj.capacitySection){
  403. this.$message.error('产能额度上浮区间为必填',1);
  404. }else if(newObj.capacitySection < 0 || newObj.capacitySection>100){
  405. this.$message.error('产能额度上浮区间必须是大于0小于100',1);
  406. }else{
  407. if(this.defaultMode == 'add'){
  408. newObj.state = '1'
  409. addSupplierList(newObj).then(res => {
  410. if (res.success) {
  411. this.$message.success('新增成功');
  412. this.getSupplierList()
  413. }else{
  414. this.$message.error(res.message);
  415. }
  416. })
  417. }else {
  418. editSupplierList(newObj).then(res => {
  419. if (res.success) {
  420. this.$message.success('修改成功');
  421. this.getSupplierList()
  422. this.selectedRowKeys = []
  423. this.selectedRows = []
  424. }else{
  425. this.$message.error(res.message);
  426. }
  427. //清空勾选恢复默认
  428. this.selectedRowKeys = []
  429. this.selectedRows = []
  430. this.defaultMode = 'add'
  431. })
  432. }
  433. }
  434. },
  435. cancelLine(){
  436. this.getSupplierList()
  437. this.defaultMode ='add'
  438. this.selectedRowKeys=[]
  439. this.selectedRows = []
  440. },
  441. subitLine(){
  442. if(this.selectedRowKeys.length ==0){
  443. this.$message.error('请勾选需要提交的数据');
  444. }else if(this.selectedRowKeys.length > 1){
  445. this.$message.error('一次只可提交一行数据');
  446. }else if(this.selectedRows[0].state == '1'){
  447. this.$message.error('不可重复提交');
  448. }else {
  449. var objNew = this.selectedRows[0]
  450. objNew.state = '1'
  451. editSupplierList(objNew).then(res => {
  452. if (res.success) {
  453. this.$message.success('提交成功');
  454. this.getSupplierList()
  455. this.selectedRowKeys = []
  456. this.selectedRows = []
  457. }else{
  458. this.$message.error(res.message);
  459. }
  460. })
  461. }
  462. },
  463. cancelSubitLine(){
  464. if(this.selectedRowKeys.length ==0){
  465. this.$message.error('请勾选需要取消提交的数据');
  466. }else if(this.selectedRowKeys.length > 1){
  467. this.$message.error('一次只可取消一行');
  468. }else if(this.selectedRows[0].state == '0'){
  469. this.$message.error('选择的数据未提交');
  470. }else{
  471. var objNew = this.selectedRows[0]
  472. objNew.state = '0'
  473. editSupplierList(objNew).then(res => {
  474. if (res.success) {
  475. this.$message.success('取消提交成功');
  476. this.getSupplierList()
  477. this.selectedRowKeys = []
  478. this.selectedRows = []
  479. }else{
  480. this.$message.error(res.message);
  481. }
  482. })
  483. }
  484. },
  485. // 选中行
  486. onSelectChange(keys, rows) {
  487. this.selectedRowKeys = keys
  488. this.selectedRows = rows
  489. },
  490. // 分页、排序、筛选变化时触发
  491. handleTableChange(pagination, filters, sorter) {
  492. // console.log('当前页信息>>>>',pagination)
  493. this.queryParam.pageNo = pagination.current
  494. this.getSupplierList()
  495. }
  496. }
  497. }
  498. </script>
  499. <style lang="less" scoped>
  500. @import '~@assets/less/common.less';
  501. @import '~@assets/less/overwriter.less';
  502. /deep/ .ant-table-thead > tr > th {
  503. text-align: center;
  504. // font-weight: 700;
  505. }
  506. /deep/ .ant-table-tbody {
  507. text-align: center;
  508. }
  509. /deep/ .ant-form-item {
  510. margin-bottom: 0;
  511. }
  512. /deep/.ant-table-tbody .ant-table-row td{
  513. padding-top: 0px;
  514. padding-bottom: 0px;
  515. }
  516. </style>