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.

471 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 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" :disabled="disabled">新增</el-button>
  5. <el-button type="primary" :loading="loading" v-if="orderNo" :disabled="disabled" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
  6. <el-button type="primary" @click="refreshPropertiesModal" :disabled="disabled" 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. 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.$store.state.user.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.$store.state.user.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. this.copyAttributeList = JSON.parse(JSON.stringify(this.dataList))
  334. this.attributeDialog = false;
  335. }
  336. },
  337. updateTestPropertiesList(){
  338. this.loading = true
  339. updatePropertiesList(this.copyAttributeList).then(({data})=>{
  340. if (data && data.code === 0){
  341. this.$message.success(data.msg);
  342. this.getProperties();
  343. this.attributeDialog = true;
  344. }else {
  345. this.$message.warning(data.msg);
  346. }
  347. this.loading = false
  348. }).catch((error)=>{
  349. this.$message.error(error)
  350. this.loading = false
  351. })
  352. },
  353. clickSaveBtn(){
  354. if (!this.attributeDialog) {
  355. this.$message.warning('请保存更改!')
  356. return
  357. }
  358. //查询 属性模板
  359. this.searchAttributeList({})
  360. this.attributeSaveDialog = true;
  361. },
  362. saveTestPropertiesItem(params){
  363. let i = 0;
  364. let arr = params.searchTableList.map(item=>{
  365. item.partNo = this.orderNo;
  366. item.site = this.$store.state.user.site;
  367. item.codeNo = this.codeNo;
  368. item.recordType = this.functionType;
  369. return item
  370. })
  371. for (let j = 0; j <arr.length ; j++) {
  372. arr[j].propertiesItemNo= arr[j].itemNo
  373. arr[j].itemNo=999
  374. }
  375. saveSubPropertiesValueForAlone(arr).then(({data})=>{
  376. if (data && data.code === 0){
  377. this.$message.success(data.msg);
  378. this.getProperties(params)
  379. }else {
  380. this.$message.warning(data.msg);
  381. }
  382. }).catch((error)=>{
  383. this.$message.error(error)
  384. })
  385. },
  386. removeTestPropertiesItem(params){
  387. for (let i = 0; i <params.dataTableList.length ; i++) {
  388. params.dataTableList[i].propertiesItemNo= params.dataTableList[i].itemNo
  389. params.dataTableList[i].itemNo=999
  390. }
  391. deleteSubPropertiesValueForAlone(params.dataTableList).then(({data})=>{
  392. if (data && data.code === 0){
  393. this.$message.success(data.msg);
  394. this.getProperties(params)
  395. }else {
  396. this.$message.warning(data.msg);
  397. }
  398. }).catch((error)=>{
  399. this.$message.error(error)
  400. })
  401. },
  402. searchAttributeList(data){
  403. let params= JSON.parse(JSON.stringify(data))
  404. params.site=this.$store.state.user.site;
  405. params.list = this.dataList;
  406. if (!this.attributeSaveDialog){
  407. this.searchDataList = [];
  408. }
  409. let inData={
  410. site:this.$store.state.user.site,
  411. functionType: this.functionType,
  412. list :this.dataList,
  413. }
  414. searchPropertiesItemList(inData).then(({data}) => {
  415. if (data && data.code === 0){
  416. this.searchDataList = data.rows;
  417. }else {
  418. this.$message.warning(data.msg)
  419. }
  420. }).catch((error)=>{
  421. this.$message.error(error)
  422. })
  423. },
  424. // getPartProperties(){
  425. // let params = {
  426. // site:this.$store.state.user.site,
  427. // partNo: this.orderNo,
  428. // codeNo: this.codeNo,
  429. // functionType: this.functionType,
  430. // }
  431. // getItemListsForPartAndCode(params).then(({data})=>{
  432. // if (data && data.code === 0){
  433. // this.dataList2 = data.rows;
  434. // }else {
  435. // this.$message.warning(data.msg)
  436. // }
  437. // }).catch((error)=>{
  438. // this.$message.error(error)
  439. // })
  440. // },
  441. },
  442. created() {
  443. this.getProperties();
  444. },
  445. }
  446. </script>
  447. <style scoped>
  448. .el-input-number /deep/ .el-input__inner {
  449. text-align: right;
  450. padding-right: 5px !important;
  451. }
  452. /deep/ .el-input .el-input--medium{
  453. line-height: 20px;
  454. }
  455. /deep/ .el-input-number .el-input--medium{
  456. line-height: 20px;
  457. }
  458. </style>