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.

523 lines
16 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <script>
  2. import {
  3. generateLabelFormatId,
  4. getLabelFormatList,
  5. removeLabelFormat,
  6. saveLabelFormat, updateLabelFormat
  7. } from '../../../api/label/labelFormat'
  8. import dayjs from 'dayjs'
  9. import FormatCustomer from './customer/formatCustomer.vue'
  10. import {getLabelFormatCustomerList} from '../../../api/label/labelFormatCustomer'
  11. import {getTableDefaultListLanguage, getTableUserListLanguage} from '../../../api/table'
  12. let labelFormat = {
  13. labelType: '',
  14. formatId: '',
  15. formatDesc: '',
  16. defaultFormat: '',
  17. remark: '',
  18. active: '',
  19. }
  20. export default {
  21. name: 'labelFormat',
  22. components: {FormatCustomer},
  23. props:{
  24. height: {
  25. type: Number,
  26. default: 350
  27. }
  28. },
  29. data(){
  30. return{
  31. labelFormat:{
  32. ...labelFormat,
  33. },
  34. saveLabelFormat: {
  35. ...labelFormat,
  36. defaultFormat: 'Y',
  37. active: 'Y',
  38. },
  39. rules:{
  40. formatDesc:[ { required: true, message: 'Please enter the format description', trigger: ['blur','change'] }],
  41. },
  42. labelFormatList:[],
  43. saveVisible: false,
  44. activeName: 'linkedCustomer',
  45. columnList:[
  46. {
  47. userId: this.$store.state.user.name,
  48. functionId: 30002,
  49. serialNumber: '30002TableLabelType',
  50. tableId: "30002Table",
  51. tableName: "标签模板信息表",
  52. columnProp: "labelType",
  53. headerAlign: "center",
  54. align: "left",
  55. columnLabel: "Label Type",
  56. columnHidden: false,
  57. columnImage: false,
  58. columnSortable: false,
  59. sortLv: 10,
  60. status: true,
  61. fixed: '',
  62. columnWidth: 80
  63. },{
  64. userId: this.$store.state.user.name,
  65. functionId: 30002,
  66. serialNumber: '30002TableFormatId',
  67. tableId: "30002Table",
  68. tableName: "标签模板信息表",
  69. columnProp: "formatId",
  70. headerAlign: "center",
  71. align: "center",
  72. columnLabel: "Format ID",
  73. columnHidden: false,
  74. columnImage: false,
  75. columnSortable: false,
  76. sortLv: 10,
  77. status: true,
  78. fixed: '',
  79. columnWidth: 180
  80. },{
  81. userId: this.$store.state.user.name,
  82. functionId: 30002,
  83. serialNumber: '30002TableFormatDesc',
  84. tableId: "30002Table",
  85. tableName: "标签模板信息表",
  86. columnProp: "formatDesc",
  87. headerAlign: "center",
  88. align: "left",
  89. columnLabel: "Format Desc",
  90. columnHidden: false,
  91. columnImage: false,
  92. columnSortable: false,
  93. sortLv: 10,
  94. status: true,
  95. fixed: '',
  96. columnWidth: 180
  97. },{
  98. userId: this.$store.state.user.name,
  99. functionId: 30002,
  100. serialNumber: '30002TableDefaultFormat',
  101. tableId: "30002Table",
  102. tableName: "标签模板信息表",
  103. columnProp: "defaultFormat",
  104. headerAlign: "center",
  105. align: "left",
  106. columnLabel: "Default Format",
  107. columnHidden: false,
  108. columnImage: false,
  109. columnSortable: false,
  110. sortLv: 10,
  111. status: true,
  112. fixed: '',
  113. columnWidth: 180
  114. },{
  115. userId: this.$store.state.user.name,
  116. functionId: 30002,
  117. serialNumber: '30002TableRemark',
  118. tableId: "30002Table",
  119. tableName: "标签模板信息表",
  120. columnProp: "remark",
  121. headerAlign: "center",
  122. align: "left",
  123. columnLabel: "Remark",
  124. columnHidden: false,
  125. columnImage: false,
  126. columnSortable: false,
  127. sortLv: 10,
  128. status: true,
  129. fixed: '',
  130. columnWidth: 180
  131. },
  132. {
  133. userId: this.$store.state.user.name,
  134. functionId: 30002,
  135. serialNumber: '30002TableCreateBy',
  136. tableId: "30002Table",
  137. tableName: "标签模板信息表",
  138. columnProp: "createBy",
  139. headerAlign: "center",
  140. align: "left",
  141. columnLabel: "Created By",
  142. columnHidden: false,
  143. columnImage: false,
  144. columnSortable: false,
  145. sortLv: 10,
  146. status: true,
  147. fixed: '',
  148. columnWidth: 80
  149. },{
  150. userId: this.$store.state.user.name,
  151. functionId: 30002,
  152. serialNumber: '30002TableCreateTime',
  153. tableId: "30002Table",
  154. tableName: "标签模板信息表",
  155. columnProp: "createTime",
  156. headerAlign: "center",
  157. align: "center",
  158. columnLabel: "Created Time",
  159. columnHidden: false,
  160. columnImage: false,
  161. columnSortable: false,
  162. sortLv: 10,
  163. status: true,
  164. fixed: '',
  165. columnWidth: 140
  166. },{
  167. userId: this.$store.state.user.name,
  168. functionId: 30002,
  169. serialNumber: '30002TableUpdateBy',
  170. tableId: "30002Table",
  171. tableName: "标签模板信息表",
  172. columnProp: "updateBy",
  173. headerAlign: "center",
  174. align: "left",
  175. columnLabel: "Updated By",
  176. columnHidden: false,
  177. columnImage: false,
  178. columnSortable: false,
  179. sortLv: 10,
  180. status: true,
  181. fixed: '',
  182. columnWidth: 80
  183. },{
  184. userId: this.$store.state.user.name,
  185. functionId: 30002,
  186. serialNumber: '30002TableUpdateTime',
  187. tableId: "30002Table",
  188. tableName: "标签模板信息表",
  189. columnProp: "updateTime",
  190. headerAlign: "center",
  191. align: "center",
  192. columnLabel: "Updated Time",
  193. columnHidden: false,
  194. columnImage: false,
  195. columnSortable: false,
  196. sortLv: 10,
  197. status: true,
  198. fixed: '',
  199. columnWidth: 140
  200. },
  201. ],
  202. labelFormatTableLoading:false,
  203. currentRow:{},
  204. customerList:[],
  205. }
  206. },
  207. watch:{
  208. currentRow(newValue, oldValue){
  209. this.getLabelFormatCustomerList();
  210. },
  211. "labelFormat.formatId"(newVal,oldVal){
  212. this.labelFormat.formatId = newVal.toUpperCase()
  213. }
  214. },
  215. methods:{
  216. handleSave(){
  217. this.saveLabelFormat = {
  218. ...labelFormat,
  219. defaultFormat: 'Y',
  220. active: 'Y',
  221. labelType: 'Shipment Carton',
  222. }
  223. let params = {
  224. site: this.$store.state.user.site,
  225. }
  226. generateLabelFormatId(params).then(({data})=>{
  227. if (data && data.code === 0){
  228. this.saveLabelFormat.formatId = data.id;
  229. this.saveVisible = true;
  230. }else {
  231. this.$message.warning(data.msg);
  232. }
  233. }).catch((error)=>{
  234. this.$message.error(error);
  235. })
  236. },
  237. getLabelFormatList(){
  238. let params = {
  239. ...this.labelFormat,
  240. site: this.$store.state.user.site,
  241. }
  242. this.labelFormatTableLoading = true;
  243. getLabelFormatList(params).then(({data})=>{
  244. if (data && data.code === 0){
  245. this.labelFormatList = data.rows;
  246. if (this.labelFormatList.length > 0){
  247. this.currentRow = this.labelFormatList[0];
  248. }
  249. }else {
  250. this.$message.warning(data.msg);
  251. }
  252. this.labelFormatTableLoading = false;
  253. }).catch((error)=>{
  254. this.$message.error(error);
  255. this.labelFormatTableLoading = false;
  256. })
  257. },
  258. handeSaveLabelFormat(){
  259. this.$refs.labelFormat.validate((valid,obj) => {
  260. if (valid){
  261. let params = {
  262. ...this.saveLabelFormat,
  263. site: this.$store.state.user.site,
  264. createBy:this.$store.state.user.name,
  265. createTime:dayjs().format('YYYY-MM-DD HH:mm:ss'),
  266. }
  267. saveLabelFormat(params).then(({data})=>{
  268. if (data && data.code === 0){
  269. this.getLabelFormatList();
  270. this.$message.success(data.msg);
  271. this.saveVisible = false;
  272. }else {
  273. this.$message.warning(data.msg);
  274. }
  275. }).catch((error)=>{
  276. this.$message.error(error);
  277. })
  278. }else{
  279. for (let i = 0; i < Object.keys(obj).length; i++) {
  280. this.$message.warning(obj[Object.keys(obj)[i]][0].message)
  281. return
  282. }
  283. }
  284. })
  285. },
  286. removeLabelFormat(row){
  287. removeLabelFormat(row).then(({data})=>{
  288. if (data && data.code === 0){
  289. this.getLabelFormatList();
  290. this.$message.success(data.msg);
  291. }else {
  292. this.$message.warning(data.msg);
  293. }
  294. }).catch((error)=>{
  295. this.$message.error(error);
  296. })
  297. },
  298. handleUpdate(row){
  299. this.saveLabelFormat = {
  300. ...row,
  301. }
  302. this.saveVisible = true;
  303. },
  304. updateLabelFormat(){
  305. this.$refs.labelFormat.validate((valid,obj) => {
  306. if (valid){
  307. let params = {
  308. ...this.saveLabelFormat,
  309. updateBy:this.$store.state.user.name,
  310. updateTime:dayjs().format('YYYY-MM-DD HH:mm:ss'),
  311. }
  312. updateLabelFormat(params).then(({data})=>{
  313. if (data && data.code === 0){
  314. this.getLabelFormatList();
  315. this.$message.success(data.msg);
  316. this.saveVisible = false;
  317. }else {
  318. this.$message.warning(data.msg);
  319. }
  320. }).catch((error)=>{
  321. this.$message.error(error);
  322. })
  323. }else{
  324. for (let i = 0; i < Object.keys(obj).length; i++) {
  325. this.$message.warning(obj[Object.keys(obj)[i]][0].message)
  326. return
  327. }
  328. }
  329. })
  330. },
  331. handleRowClick(row , column, event){
  332. this.currentRow = {...row};
  333. },
  334. rowLabelFormatStyle({row}){
  335. if (row.formatId === this.currentRow.formatId){
  336. return {
  337. background: 'rgb(232,246,246)',
  338. }
  339. }
  340. },
  341. getLabelFormatCustomerList(){
  342. let params = {
  343. site:this.currentRow.site,
  344. formatId:this.currentRow.formatId,
  345. }
  346. getLabelFormatCustomerList(params).then(({data})=>{
  347. if (data && data.code === 0){
  348. this.customerList = data.rows;
  349. }else {
  350. this.$message.warning(data.msg);
  351. }
  352. }).catch((error)=>{
  353. this.$message.error(error);
  354. })
  355. },
  356. async getTableUserColumn (tableId, columnId) {
  357. let queryTableUser = {
  358. userId: this.$store.state.user.name,
  359. functionId: this.$route.meta.menuId,
  360. tableId: tableId,
  361. status: true,
  362. languageCode: this.$i18n.locale
  363. }
  364. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  365. if (data.rows.length > 0) {
  366. this.caseTable(data.rows,columnId)
  367. } else {
  368. this.getColumnList(tableId, columnId)
  369. }
  370. })
  371. },
  372. // 获取 tableDefault 列
  373. async getColumnList (tableId, columnId) {
  374. let queryTable = {
  375. functionId: this.$route.meta.menuId,
  376. tableId: tableId,
  377. languageCode: this.$i18n.locale
  378. }
  379. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  380. if (!data.rows.length === 0) {
  381. this.caseTable(data.rows,columnId)
  382. } else {
  383. }
  384. })
  385. },
  386. caseTable(list,columnId){
  387. if (list.length > 0){
  388. switch (columnId) {
  389. case 1:
  390. this.columnList = list
  391. break;
  392. }
  393. }
  394. },
  395. },
  396. created () {
  397. this.getLabelFormatList();
  398. this.getTableUserColumn("30002Table",1)
  399. }
  400. }
  401. </script>
  402. <template>
  403. <div>
  404. <el-form :inline="true" label-position="top" :model="labelFormat">
  405. <el-form-item label="Label Type">
  406. <el-select v-model="labelFormat.labelType" placeholder="">
  407. <el-option label="All" value=""></el-option>
  408. <el-option label="Shipment Carton" value="Shipment Carton"></el-option>
  409. <el-option label="Roll Label" value="Roll Label"></el-option>
  410. </el-select>
  411. </el-form-item>
  412. <el-form-item label="Format ID">
  413. <el-input v-model="labelFormat.formatId"></el-input>
  414. </el-form-item>
  415. <el-form-item label="Format Desc">
  416. <el-input v-model="labelFormat.formatDesc"></el-input>
  417. </el-form-item>
  418. <el-form-item label="Active">
  419. <el-select v-model="labelFormat.active" placeholder="">
  420. <el-option label="All" value=""></el-option>
  421. <el-option label="Active" value="Y"></el-option>
  422. <el-option label="Not Active" value="N"></el-option>
  423. </el-select>
  424. </el-form-item>
  425. <el-form-item label=" ">
  426. <el-button type="primary" @click="handleSave">New</el-button>
  427. <el-button type="primary" @click="getLabelFormatList">Query</el-button>
  428. </el-form-item>
  429. </el-form>
  430. <el-table :data="labelFormatList" :row-style="rowLabelFormatStyle" @row-click="handleRowClick" :loading="labelFormatTableLoading" border style="width: 100%;margin-top: 5px" :height="height">
  431. <el-table-column
  432. header-align="center"
  433. align="center"
  434. width="100"
  435. fixed="left"
  436. label="Actions">
  437. <template slot-scope="scope">
  438. <el-link style="cursor:pointer;" @click="handleUpdate(scope.row)">Edit</el-link>
  439. <el-link style="cursor:pointer;" @click="removeLabelFormat(scope.row)">Delete</el-link>
  440. </template>
  441. </el-table-column>
  442. <el-table-column
  443. v-for="(item,index) in columnList" :key="index"
  444. :sortable="item.columnSortable"
  445. :prop="item.columnProp"
  446. :header-align="item.headerAlign"
  447. :show-overflow-tooltip="item.showOverflowTooltip"
  448. :align="item.align"
  449. :fixed="item.fixed===''?false:item.fixed"
  450. :min-width="item.columnWidth"
  451. :label="item.columnLabel">
  452. <template slot-scope="scope">
  453. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  454. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  455. style="width: 100px; height: 80px"/></span>
  456. </template>
  457. </el-table-column>
  458. </el-table>
  459. <el-tabs v-model="activeName">
  460. <el-tab-pane label="Linked Customer" name="linkedCustomer">
  461. <format-customer :label-format="currentRow" :data-list="customerList" @refresh="getLabelFormatCustomerList"></format-customer>
  462. </el-tab-pane>
  463. </el-tabs>
  464. <el-dialog v-drag :title="`Label Format`" :close-on-click-modal="false" :visible.sync="saveVisible" width="600px">
  465. <el-form :model="saveLabelFormat" label-position="top" :rules="rules" ref="labelFormat">
  466. <el-row :gutter="20">
  467. <el-col :span="6">
  468. <el-form-item label="Label Type">
  469. <el-select v-model="saveLabelFormat.labelType" placeholder="" :disabled="saveLabelFormat.site" style="width: 100%">
  470. <el-option label="Shipment Carton" value="Shipment Carton"></el-option>
  471. <el-option label="Roll Label" value="Roll Label"></el-option>
  472. </el-select>
  473. </el-form-item>
  474. </el-col>
  475. <el-col :span="12">
  476. <el-form-item label="Format ID">
  477. <el-input readonly disabled v-model="saveLabelFormat.formatId"></el-input>
  478. </el-form-item>
  479. </el-col>
  480. <el-col :span="6">
  481. <el-form-item label=" ">
  482. <el-checkbox v-model="saveLabelFormat.defaultFormat" true-label="Y" false-label="N"> Default Format </el-checkbox>
  483. </el-form-item>
  484. </el-col>
  485. <el-col :span="18">
  486. <el-form-item label="Format Desc" prop="formatDesc" :show-message="false">
  487. <el-input v-model="saveLabelFormat.formatDesc"></el-input>
  488. </el-form-item>
  489. </el-col>
  490. <el-col :span="6">
  491. <el-form-item label=" ">
  492. <el-checkbox v-model="saveLabelFormat.active" true-label="Y" false-label="N"> Active </el-checkbox>
  493. </el-form-item>
  494. </el-col>
  495. <el-col :span="24">
  496. <el-form-item label="Remark" class="remark">
  497. <el-input type="textarea" v-model="saveLabelFormat.remark" :rows="3" resize="none"></el-input>
  498. </el-form-item>
  499. </el-col>
  500. </el-row>
  501. </el-form>
  502. <div slot="footer" class="dialog-footer">
  503. <el-button type="primary" v-if="saveLabelFormat.site" @click="updateLabelFormat">Save</el-button>
  504. <el-button type="primary" v-else @click="handeSaveLabelFormat">Save</el-button>
  505. <el-button @click="saveVisible=false">Cancel</el-button>
  506. </div>
  507. </el-dialog>
  508. </div>
  509. </template>
  510. <style scoped>
  511. .remark /deep/ .el-form-item__content{
  512. height: auto;
  513. line-height: 1.5;
  514. }
  515. </style>