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.

468 lines
15 KiB

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