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.

467 lines
15 KiB

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