plm前端
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.

475 lines
15 KiB

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