supplier-capacity.vue 17 KB

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