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.

440 lines
14 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 days ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <div>
  3. <div style="margin-top: 5px">
  4. <template >
  5. <el-button type="primary" @click="clickSaveBtn" v-if="orderNo" :disabled="disabled">新增</el-button>
  6. </template>
  7. <template >
  8. <el-button type="primary" :loading="loading" v-if="orderNo" :disabled="disabled" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
  9. </template>
  10. </div>
  11. <div class="rq " v-if="attributeDialog">
  12. <el-table
  13. :height="height"
  14. :data="dataList"
  15. border
  16. style="width: 100%;margin-top: 5px">
  17. <el-table-column
  18. v-for="(item,index) in productColumnList" :key="index"
  19. :sortable="item.columnSortable"
  20. :prop="item.columnProp"
  21. :header-align="item.headerAlign"
  22. :show-overflow-tooltip="item.showOverflowTooltip"
  23. :align="item.align"
  24. :fixed="item.fixed===''?false:item.fixed"
  25. :min-width="item.columnWidth"
  26. :label="item.columnLabel">
  27. <template slot-scope="scope">
  28. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  29. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  30. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  31. </div>
  32. <div v-else>
  33. {{scope.row.valueTypeDb==='T'?scope.row.textValue:scope.row.numValue}}
  34. </div>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. <div class="rq " v-else>
  40. <el-table
  41. :height="height"
  42. :data="copyAttributeList"
  43. border
  44. style="width: 100%;margin-top: 5px">
  45. <el-table-column
  46. v-for="(item,index) in productColumnList" :key="index"
  47. :sortable="item.columnSortable"
  48. :prop="item.columnProp"
  49. :header-align="item.headerAlign"
  50. :show-overflow-tooltip="item.showOverflowTooltip"
  51. :align="item.align"
  52. :fixed="item.fixed===''?false:item.fixed"
  53. :min-width="item.columnWidth"
  54. :label="item.columnLabel">
  55. <template slot-scope="scope">
  56. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  57. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  58. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  59. </div>
  60. <div v-else>
  61. <div v-if="scope.row.valueChooseFlag !== 'Y'">
  62. <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueType === '数字'" :controls="false"></el-input-number>
  63. <el-input v-model="scope.row.textValue" v-else></el-input>
  64. </div>
  65. <div v-else>
  66. <el-select style="width: 100%;" v-if="scope.row.valueType === '文本'" v-model="scope.row.textValue">
  67. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
  68. </el-select>
  69. <el-select style="width: 100%;" v-else v-model="scope.row.numValue">
  70. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
  71. </el-select>
  72. </div>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. </div>
  78. <el-dialog title="属性项目" v-drag :visible.sync="attributeSaveDialog" append-to-body>
  79. <transfer-table v-if="attributeSaveDialog"
  80. v-model="dataList2"
  81. :data-list="searchDataList"
  82. @add="saveTestPropertiesItem"
  83. @delete="removeTestPropertiesItem"
  84. @search="searchAttributeList"></transfer-table>
  85. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  86. <el-button type="primary" @click="attributeSaveDialog = false">关闭</el-button>
  87. </el-footer>
  88. </el-dialog>
  89. </div>
  90. </template>
  91. <script>
  92. import {updatePropertiesList,getPropertiesListByPartAndCodeNo
  93. ,searchPropertiesItemList,saveSubPropertiesValueForAlone,deleteSubPropertiesValueForAlone
  94. } from "@/api/ecss/ecss.js";
  95. import TransferTable from "../common/transferTable.vue";
  96. export default {
  97. name: "orderAttribute",
  98. components: {TransferTable},
  99. props:{
  100. site:{
  101. type:String,
  102. },
  103. buNo:{
  104. type:String,
  105. },
  106. orderNo:{
  107. type:String,
  108. },
  109. codeNo:{
  110. type:String,
  111. },
  112. functionType:{
  113. type:String,
  114. },
  115. disabled:{
  116. type:Boolean,
  117. default:false,
  118. }
  119. },
  120. data(){
  121. return{
  122. height:320,
  123. loading:false,
  124. attributeDialog:true,
  125. copyAttributeList:[],
  126. attributeSaveDialog:false,
  127. productColumnList: [
  128. {
  129. userId: this.$store.state.user.name,
  130. functionId: 100002001,
  131. serialNumber: '100002001TablePropertiesItemNo',
  132. tableId: "100002001Table",
  133. tableName: "属性表",
  134. columnProp: 'propertiesItemNo',
  135. headerAlign: "center",
  136. align: "left",
  137. columnLabel: '属性编码',
  138. columnHidden: false,
  139. columnImage: false,
  140. columnSortable: false,
  141. sortLv: 0,
  142. status: true,
  143. fixed: '',
  144. },{
  145. userId: this.$store.state.user.name,
  146. functionId: 100002001,
  147. serialNumber: '100002001TableItemDesc',
  148. tableId: "100002001Table",
  149. tableName: "属性表",
  150. columnProp: 'itemDesc',
  151. headerAlign: "center",
  152. align: "left",
  153. columnLabel: '属性名称',
  154. columnHidden: false,
  155. columnImage: false,
  156. columnSortable: false,
  157. sortLv: 0,
  158. status: true,
  159. fixed: '',
  160. },
  161. {
  162. userId: this.$store.state.user.name,
  163. functionId: 100002001,
  164. serialNumber: '100002001TableValueType',
  165. tableId: "100002001Table",
  166. tableName: "属性表",
  167. columnProp: 'valueType',
  168. headerAlign: "center",
  169. align: "center",
  170. columnLabel: '值类型',
  171. columnHidden: false,
  172. columnImage: false,
  173. columnSortable: false,
  174. sortLv: 0,
  175. status: true,
  176. fixed: '',
  177. columnWidth:80,
  178. },
  179. // {
  180. // userId: this.$store.state.user.name,
  181. // functionId: 100002001,
  182. // serialNumber: '100002001TableMinValue',
  183. // tableId: "100002001Table",
  184. // tableName: "属性表",
  185. // columnProp: 'minValue',
  186. // headerAlign: "center",
  187. // align: "center",
  188. // columnLabel: '最小值',
  189. // columnHidden: false,
  190. // columnImage: false,
  191. // columnSortable: false,
  192. // sortLv: 0,
  193. // status: true,
  194. // fixed: '',
  195. // columnWidth:80,
  196. // },{
  197. // userId: this.$store.state.user.name,
  198. // functionId: 100002001,
  199. // serialNumber: '100002001TableMaxValue',
  200. // tableId: "100002001Table",
  201. // tableName: "属性表",
  202. // columnProp: 'maxValue',
  203. // headerAlign: "center",
  204. // align: "center",
  205. // columnLabel: '最大值',
  206. // columnHidden: false,
  207. // columnImage: false,
  208. // columnSortable: false,
  209. // sortLv: 0,
  210. // status: true,
  211. // fixed: '',
  212. // columnWidth:80,
  213. // },
  214. {
  215. userId: this.$store.state.user.name,
  216. functionId: 100002001,
  217. serialNumber: '100002001TableMaxValue',
  218. tableId: "100002001Table",
  219. tableName: "属性表",
  220. columnProp: 'textValue',
  221. headerAlign: "center",
  222. align: "left",
  223. columnLabel: '属性值',
  224. columnHidden: false,
  225. columnImage: false,
  226. columnSortable: false,
  227. sortLv: 0,
  228. status: true,
  229. fixed: '',
  230. columnWidth:120,
  231. },
  232. // {
  233. // userId: this.$store.state.user.name,
  234. // functionId: 100002001,
  235. // serialNumber: '100002001TableMinValue',
  236. // tableId: "100002001Table",
  237. // tableName: "属性表",
  238. // columnProp: 'numValue',
  239. // headerAlign: "center",
  240. // align: "right",
  241. // columnLabel: '数字值',
  242. // columnHidden: false,
  243. // columnImage: false,
  244. // columnSortable: false,
  245. // sortLv: 0,
  246. // status: true,
  247. // fixed: '',
  248. // columnWidth:120,
  249. // },
  250. // {
  251. // userId: this.$store.state.user.name,
  252. // functionId: 100002001,
  253. // serialNumber: '100002001TableDefaultValue',
  254. // tableId: "100002001Table",
  255. // tableName: "属性表",
  256. // columnProp: 'defaultValue',
  257. // headerAlign: "center",
  258. // align: "right",
  259. // columnLabel: '参照值',
  260. // columnHidden: false,
  261. // columnImage: false,
  262. // columnSortable: false,
  263. // sortLv: 0,
  264. // status: true,
  265. // fixed: '',
  266. // },
  267. ],
  268. searchDataList:[],
  269. dataList:[],
  270. dataList2:[],
  271. }
  272. },
  273. watch:{
  274. orderNo(newValue,oldValue){
  275. if (newValue){
  276. this.getProperties();
  277. }
  278. },
  279. },
  280. methods:{
  281. getProperties(){
  282. let params = {
  283. site:this.site,
  284. buNo:this.buNo,
  285. partNo: this.orderNo,
  286. codeNo: this.codeNo,
  287. recordType: this.functionType,
  288. }
  289. getPropertiesListByPartAndCodeNo(params).then(({data})=>{
  290. if (data && data.code === 0){
  291. this.dataList = data.rows;
  292. this.dataList2 = JSON.parse(JSON.stringify(data.rows));
  293. for (let i = 0; i <this.dataList2.length ; i++) {
  294. this.dataList2[i].itemNo= this.dataList2[i].propertiesItemNo
  295. }
  296. this.searchAttributeList({})
  297. }else {
  298. this.$message.warning(data.msg)
  299. }
  300. }).catch((error)=>{
  301. this.$message.error(error)
  302. })
  303. },
  304. clickSave(){
  305. if(this.dataList.length==0){
  306. return false
  307. }
  308. if (!this.attributeDialog){
  309. this.updateTestPropertiesList();
  310. }else {
  311. this.copyAttributeList = JSON.parse(JSON.stringify(this.dataList))
  312. this.attributeDialog = false;
  313. }
  314. },
  315. updateTestPropertiesList(){
  316. this.loading = true
  317. updatePropertiesList(this.copyAttributeList).then(({data})=>{
  318. if (data && data.code === 0){
  319. this.$message.success('操作成功');
  320. this.getProperties();
  321. this.attributeDialog = true;
  322. }else {
  323. this.$message.warning(data.msg);
  324. }
  325. this.loading = false
  326. }).catch((error)=>{
  327. this.$message.error(error)
  328. this.loading = false
  329. })
  330. },
  331. clickSaveBtn(){
  332. if (!this.attributeDialog) {
  333. this.$message.warning('请保存更改!')
  334. return
  335. }
  336. //查询 属性模板
  337. this.searchAttributeList({})
  338. this.attributeSaveDialog = true;
  339. },
  340. saveTestPropertiesItem(params){
  341. let i = 0;
  342. let arr = params.searchTableList.map(item=>{
  343. item.partNo = this.orderNo;
  344. item.site = this.$store.state.user.site;
  345. item.codeNo = this.codeNo;
  346. item.recordType = this.functionType;
  347. return item
  348. })
  349. for (let j = 0; j <arr.length ; j++) {
  350. arr[j].propertiesItemNo= arr[j].itemNo
  351. arr[j].itemNo=999
  352. }
  353. saveSubPropertiesValueForAlone(arr).then(({data})=>{
  354. if (data && data.code === 0){
  355. this.$message.success('操作成功');
  356. this.getProperties(params)
  357. }else {
  358. this.$message.warning(data.msg);
  359. }
  360. }).catch((error)=>{
  361. this.$message.error(error)
  362. })
  363. },
  364. removeTestPropertiesItem(params){
  365. for (let i = 0; i <params.dataTableList.length ; i++) {
  366. params.dataTableList[i].propertiesItemNo= params.dataTableList[i].itemNo
  367. params.dataTableList[i].itemNo=999
  368. }
  369. deleteSubPropertiesValueForAlone(params.dataTableList).then(({data})=>{
  370. if (data && data.code === 0){
  371. this.$message.success('操作成功');
  372. this.getProperties(params)
  373. }else {
  374. this.$message.warning(data.msg);
  375. }
  376. }).catch((error)=>{
  377. this.$message.error(error)
  378. })
  379. },
  380. searchAttributeList(data){
  381. let params= JSON.parse(JSON.stringify(data))
  382. params.site=this.$store.state.user.site;
  383. params.list = this.dataList;
  384. if (!this.attributeSaveDialog){
  385. this.searchDataList = [];
  386. }
  387. let inData={
  388. site:this.site,
  389. functionType: this.functionType,
  390. list :this.dataList,
  391. codeNo: this.codeNo,
  392. buNo:this.buNo,
  393. }
  394. searchPropertiesItemList(inData).then(({data}) => {
  395. if (data && data.code === 0){
  396. this.searchDataList = data.rows;
  397. }else {
  398. this.$message.warning(data.msg)
  399. }
  400. }).catch((error)=>{
  401. this.$message.error(error)
  402. })
  403. },
  404. },
  405. mounted() {
  406. this.$nextTick(() => {
  407. this.height = (window.innerHeight - 240)/2;
  408. })
  409. },
  410. created(){
  411. this.getProperties();
  412. },
  413. }
  414. </script>
  415. <style scoped>
  416. .el-input-number /deep/ .el-input__inner {
  417. text-align: right;
  418. padding-right: 5px !important;
  419. }
  420. /deep/ .el-input .el-input--medium{
  421. line-height: 20px;
  422. }
  423. /deep/ .el-input-number .el-input--medium{
  424. line-height: 20px;
  425. }
  426. </style>