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.

480 lines
15 KiB

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